1

I had recently tried reinstalling Python, and after Python was installed successfully, after activating my virtual environment using pipenv shell whenever I try to run python manage.py I get the following errors:

Traceback (most recent call last):
  File "manage.py", line 10, in main
    from django.core.management import execute_from_command_line
  File "C:\Users\moaha\.virtualenvs\restapi-Ks1Qcdgf\lib\site-packages\django\__init__.py", line 1, in <module>     
    from django.utils.version import get_version
  File "C:\Users\moaha\.virtualenvs\restapi-Ks1Qcdgf\lib\site-packages\django\utils\version.py", line 1, in <module>
    import datetime
ModuleNotFoundError: No module named 'datetime'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 16, in main
    ) from exc
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a 
virtual environment?

Python on its own works fine, and pipenv also works (activates the environment properly), and I've tried to run updates on pip and pipenv. I'm not really sure what is going on and how to fix this issue.

Heres how my Environment Variables > Path look like:

C:\Program Files (x86)\Python37-32\Scripts\

C:\Program Files (x86)\Python37-32\

Also, sometimes I get a runpy error, not sure if it is related in anyway. However, I am unable to replicate the runpy issue.

I sincerely appreciate any help. Thanks!

0

1 Answer 1

1

I was able to "solve" (I guess it's more like a hack job?) this issue by going into the .virtualenvs folder, located in C:\Users\<user>\.virtualenvs, and deleting all the project folders that had the issue, and use the > pipenv shell followed by > pipenv install to install all dependencies.

1
  • Thanks for this answer. =) Aug 17, 2019 at 8:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.