Reputation: 167
I have a mac and python 2.something installed. I recently installed python3 and pip3. Then I tried running the following commands:
pip3 install django==2.2
django-admin startproject myProject
cd myProject
everything worked, but when I run
python3 manage.py runserver
it complains
Traceback (most recent call last):
File "manage.py", line 10, in main
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
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?
is my computer still thinking in the old version? I am not familiar with "environment variables" do I need to modify it? (I am asking cause I also read that it can be unsafe to modify that stuff)
Also, when I run
python --version
it gives me 2.7
however I can still run .py files using "python3" command
Upvotes: 2
Views: 143
Reputation: 24038
If you don't want to use a virtual environment. I would suggest not trying to substitute python
with python3
just yet, since you might still have programs that depend on Python 2.
Instead, you can try to install django with the command:
python3 -m pip install django==2.2
Upvotes: 2
Reputation: 160
try using first python3 -m pip install django
and then run the command python3 manage.py runserver
looks like you are installing django on Python 2
Upvotes: 4