19π
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
55π
I had the same error, and this fix my issue
python -m pip install django
π Done!
- [Django]-Why does Django's render() function need the "request" argument?
- [Django]-What's the best way to migrate a Django DB from SQLite to MySQL?
- [Django]-AngularJS with Django β Conflicting template tags
16π
Under linux, you can set the PYTHONPATH environment variable in your .profile or .bashrc. You can either edit it directly from the terminal by changing to your home directory (cd ~), and then edit the file (nano .bashrc), or by opening the file with gtkedit or vim or whatever, and add:
PYTHONPATH=/usr/local/lib/python2.7/site-packages:/another/path/etc
If you want to test this before editing your profile, you can export this from the terminal as:
export PYTHONPATH=/local/lib/python2.7/site-packages
Iβm assuming youβre running this straight from the command line. If youβre running it as a wsgi module in apache, you can add this to your syspath from your wsgi file as:
import sys
sys.path.append('/usr/local/lib/python2.7/site-packages')
- [Django]-Django "login() takes exactly 1 argument (2 given)" error
- [Django]-Access tuple in django template
- [Django]-How can I make a Django form field contain only alphanumeric characters
13π
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)
- [Django]-Can I use Django F() objects with string concatenation?
- [Django]-Python Django Rest Framework UnorderedObjectListWarning
- [Django]-110: Connection timed out (Nginx/Gunicorn)
11π
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
>>>
- [Django]-How to dynamically set the queryset of a models.ModelChoiceField on a forms.Form subclass
- [Django]-Iterate over model instance field names and values in template
- [Django]-Using django-admin on windows powershell
3π
django went missing with an upgrade to python 3.7
pip3 install django
fixed the problem.
- [Django]-Django: invalid literal for int() with base 10
- [Django]-Chaining multiple filter() in Django, is this a bug?
- [Django]-Get class name for empty queryset in django
1π
If you are using a environment use:
$ <environment_location>/<environment_name>/bin/python manage.py runserver
- [Django]-How can I render a ManyToManyField as checkboxes?
- [Django]-Limit number of characters with Django Template filter
- [Django]-Django: get table name of a model in the model manager?
- [Django]-Plug in django-allauth as endpoint in django-rest-framework
- [Django]-Django and VirtualEnv Development/Deployment Best Practices
- [Django]-Django model method β create_or_update
0π
I also had same error but easily solved it .those who are using version 4 and above of Django and python 3.0 can do the following(for windows)
pip install virtualenv #installs virtual environment in pc
py -m venv myvenv #creates virtual environment named myvenv inside folder
myvenv/Scripts/activate # activates the virtual environment
You are now ready to go.
pip install django # pip install django
python -m django βversion # checks the version of installed django
- [Django]-How to change the Django admin filter to use a dropdown instead of list?
- [Django]-Django admin, hide a model
- [Django]-How to check DEBUG true/false in django template β exactly in layout.html