I am using centos linux.
I had python 2.6 with django and now i upgraded to python 2.7.
Python 2.6 is located in /usr/lib/python2.6.
Python 2.7 is located i
django went missing with an upgrade to python 3.7
pip3 install django
fixed the problem.
To check your path, you can use the following code:
import sys
print(sys.path)
If you already know where django is installed, it should be easy to test if the desired directory is in your path with directory in sys.path
.
Regarding where your PYTHONPATH
is defined, note that it's an environment variable, so you can check its value (if defined) with: echo $PYTHONPATH
If you are using a enviroment use:
$ ~/Documents/backend/environment/bin/python -m mypy ~/Documents/backend/src/file.py
Try printing sys.path
to see what's in your path. Django need to be in one of the dirs listed. Example on Windows:
>>> import sys
>>> for p in sys.path: print p
C:\Python27\Lib\idlelib
C:\Windows\system32\python27.zip
C:\Python27\DLLs
C:\Python27\lib
C:\Python27\lib\plat-win
C:\Python27\lib\lib-tk
C:\Python27
C:\Python27\lib\site-packages
>>>
I had the same error, and this fix my issue
python -m pip install django
:) Done!
try
pip freeze
this command show which packages are installed in your system then run with root privilege
pip install django
then create a new project with command
django-admin.py startproject mysite
then start your project
cd path/to/mysite
./manage.py runserver
in file wsgi.py add this lines
import os
import sys
DJANGO_PATH = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..')
sys.path.append(DJANGO_PATH)