62π
Probably, pip
installs packages into dist-packages
directory, which is not included into PYTHONPATH
environment variable. You have a couple of solutions:
- Create and configure
virtualenv
for your project, before usingpip
. This is the most Pythonic way -
Try to install
Django
using built-in pip module:python -m pip install django
This command should install packages into
site-packages
directory. - You may also add
dist-packages
to yourPYTHONPATH
. This question should help you: How to globally modify the default PYTHONPATH (sys.path)?
9π
This error shows that Django is not installed. Installing Django should solve the problem.
In my case, Django was there in my virtualenv but while using gunicorn I was getting this error then later I realized gunicorn was dealing with my globally install python environment not my virtual environment installing Django on my global python env simply solved my issue.
pip install django
- [Django]-How to get getting base_url in django template
- [Django]-Django: show a ManyToManyField in a template?
- [Django]-Django model manager objects.create where is the documentation?
7π
I got this error when using
python manage.py runserver #python version 3 was being used
Solved the problem by using:
python2 manage.py runserver #python version 2
- [Django]-Django: get table name of a model in the model manager?
- [Django]-What is the purpose of NGINX and Gunicorn running in parallel?
- [Django]-How to reverse the URL of a ViewSet's custom action in django restframework
7π
I had the similar error for other modules which are already installed, executing same command as superuser:
sudo pip3 install -r requirements.txt
solved my issue.
- [Django]-Django: Implementing a Form within a generic DetailView
- [Django]-How do I restrict foreign keys choices to related objects only in django
- [Django]-Can't connect to local MySQL server through socket '/tmp/mysql.sock
4π
You need to close the other active virtual environment in your machine if youβre using virtualenv, and make sure django installed. Go to python3 interpreter and run this:
>>>from django import get_version
>>>get_version()
make sure it show you this β2.1.4β
- [Django]-Django migrations RunPython not able to call model methods
- [Django]-Django: how save bytes object to models.FileField?
- [Django]-Access request in django custom template tags
3π
For Mac users; If youβve previously downloaded and installed python3, just running python
via the terminal shell defaults to using the pre-installed python v2, which will not recognise your installation of django (unless you install it via the python2 module) and youβll probably get an error when you check the version:
$ python
>>> from django import get_version
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named django
Try starting python using:
$ python3
Then try:
>>> from django import get_version
>>> get_version()
You should get the output:
'2.0.3'
- [Django]-How do I include image files in Django templates?
- [Django]-How to compare dates in Django templates
- [Django]-In the Django admin site, how do I change the display format of time fields?
3π
python3 manage.py migrate
solved my problem
I was getting this error while running:
python manage.py migrate
I changed to python3 ...
- [Django]-How do I integrate Ajax with Django applications?
- [Django]-Assign variables to child template in {% include %} tag Django
- [Django]-Django 1.7 β App 'your_app_name' does not have migrations
2π
I had given the dependency in requirements.txt
as Django==2.0.7
. So after activating the virtual environment, if you are receiving the message, try installing the requirements:
pip install -r requirements.txt
- [Django]-How to filter objects for count annotation in Django?
- [Django]-Django β after login, redirect user to his custom page β> mysite.com/username
- [Django]-Naming convention for Django URL, templates, models and views
1π
I also faced the same problem. i was using python 3.7 and installed django 2.2. So i degraded my python to 3.6 and installed django 2.2, and without having a virtualenv.
- [Django]-Error: "dictionary update sequence element #0 has length 1; 2 is required" on Django 1.4
- [Django]-How to PATCH a single field using Django Rest Framework?
- [Django]-Django REST Framework: how to substitute null with empty string?
1π
I got the same issue today. doing pip3 install django
or pip3 install -r requirements.txt
solved it.
- [Django]-Testing email sending in Django
- [Django]-Django Rest Framework: Disable field update after object is created
- [Django]-Good open source django project for learning
1π
Try updating the Django.
I was getting the same issue because I had an older version of Django installed. I installed the latest version of Django instead and it fixed my issue.
- [Django]-Django serializer inherit and extend fields
- [Django]-Django modelform NOT required field
- [Django]-Django ModelForm override widget
0π
I faced same issue with you when try to setup Apache work with Django.
Issue solve after add Pythonpath to Apache2.conf as bellow:
WSGIPythonPath/opt/djangoprojects/myproject:opt/anaconda3/lib/python3.6/site-packages
I installed Python3 before.
- [Django]-Django model method β create_or_update
- [Django]-Constructing Django filter queries dynamically with args and kwargs
- [Django]-Django release 1.5: 'url' requires a non-empty first argument. The syntax changed in Django 1.5
0π
This error shows you didnβt install Django. Installing Django should solve the problem.
Once you do, you can just check the path of βdjangoβ using:
>>> sys.path
- [Django]-ValueError: Missing staticfiles manifest entry for 'favicon.ico'
- [Django]-Inline in ModelForm
- [Django]-How to make an auto-filled and auto-incrementing field in django admin
0π
For MacOs,I was getting the same issue while using import django.I deactivated conda and again activated django virtual environment by conda.Then made sure the python version is correct,in my case it was python 3.8.5.Then navigate to the projectβs directory and run the required python script.
My Django version is 3.1.5
- [Django]-Django models β how to filter number of ForeignKey objects
- [Django]-ImproperlyConfigured: The included urlconf <project>.urls doesn't have any patterns in it
- [Django]-How to force Django models to be released from memory
0π
Unistall/Install
Confirm that youβre running from virtualenv of you have installed the app to venv.
If you made sure that it has been installed and still shows mdule not found, uninstall and install again.
- [Django]-How to completely dump the data for Django-CMS
- [Django]-Django Test Client Method Override Header
- [Django]-DRF: Simple foreign key assignment with nested serializers?
0π
Maybe your env
not running after you shut down your computer. Just need to pipenv shell
to launch again the virtual environment.
Then u can see this one the terminal
Launching subshell in virtual environment...
. /Users/.../.local/share/virtualenvs/little-lemon-O3-M0emD/bin/activate
and, type python3 manage.py runserver
to start your django server and work normally.
- [Django]-Why does my Django admin site not have styles / CSS loading?
- [Django]-"Post Image data using POSTMAN"
- [Django]-Django 1.7 β App 'your_app_name' does not have migrations
0π
make sure you created your app properly and define it in settings.py
file.
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
....
'app_name.apps.AppNameConfig',
]
sometimes, not defining your app name in settings.py
or unwanted typo causes the same type of error.
- [Django]-What is the meaning of bind = True keyword in celery?
- [Django]-How do I make an auto increment integer field in Django?
- [Django]-What is the function of the name parameter in django.urls.path?