I have two versions of python 2.7 and 3.4 and installed django through pip. it shows in ubuntu terminal:
$ pip freeze Django==1.6.11 $ pip --version pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7) $ python Python 2.7.9 (default, Feb 3 2016, 02:50:32) [GCC 4.8.4] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>import django Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named django >>> import sys >>> sys.path ['', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7', '/usr/local/lib/python2.7/plat-linux2', '/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old', '/usr/local/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/site-packages'] >>>
Any idea??
score: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.
score: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
Some more answer related to the same question
- No module named django but it is installed
- can't connect django 1.10 to mysql 5.7, mysqlclient installed but still get ImportError: No module named 'MySQLdb'
- ImportError: No module named cms when running Django with django-cms installed
- During massive Django code reorg, "No module named foobar"; foo and bar are part of my app, but not foobar
- Upgrade python to 2.7 and Django to 1.4, but it tells me No module named *
- No module named 'social_django' but 'social-auth-app-django' is installed
- django import error - No module named core.management
- Django Rest Framework -- no module named rest_framework
- Django - "no module named django.core.management"
- Django import error - no module named django.conf.urls.defaults
score: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
score: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.
Related question
- "No module named simple" error in Django
- Running django tutorial tests fail - No module named polls.tests
- No module named 'polls.apps.PollsConfigdjango'; Django project tutorial 2
- ImportError: No module named django.core.handlers.wsgi in install django mod_wsgi config on apache
- Import Error: No module named django
- Django Shell No module named settings
- Getting stuck at Django error: No module named registration
- Django Import Error: No module named apps
- Python Django : No module named security
- Django - No module named _sqlite3
score: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.
score:1
python3 manage.py migrate
solved my problem
I was getting this error while running:
python manage.py migrate
I changed to python3 ...
score: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.
score:2
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'
score:2
I got the same issue today. doing pip3 install django
or pip3 install -r requirements.txt
solved it.
score:3
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
score: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'
score:5
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.
score:6
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
score:8
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
score:58
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)?
Credit To: stackoverflow.com
Related Query
- Django 1.5b1: executing django-admin.py causes "No module named settings" error
- Django No module named 'django.db.migrations.migration'
- Django and Celery - ModuleNotFoundError: No module named 'celery.task'
- Django storages: Import Error - no module named storages
- Django can' t load Module 'debug_toolbar': No module named 'debug_toolbar'
- No module named settings_vars error in django debug toolbar
- Updating Django - error: 'No module named migration'
- Django & Heroku - ImportError: No module named gettingstarted.wsgi
- django + virtualenv + gunicorn - No module named django.core.wsgi?
- Django + mod_wsgi + apache: ImportError at / No module named djproj.urls
More Query from same tag
- How to configure static serving in twisted with django
- Authentication credentials were not provided with djangorestframework-jwt
- HttpResponse Django does not change file name
- Getting 'TooBig' Memcachier exception on a Django Rest Framework response on Heroku
- Serving static admin files for Django 1.5 in a shared hosting environment
- Celery, what is the recommended way to deamonise as a worker and a scheduler?
- Retaining state between Django views
- Running/Stopping Django Development Server In Electron
- Pisa pdf converter is very slow with large tables
- Django cannot unpack non-iterable 'Q' object
- Python Package Paths :: Finding Directories that Should Be .py Files
- multiple independent blog accounts with python based framework
- Django logout(redirect to home page) .. Delete cookie?
- Reverse for 'user' with arguments '('',)' not found. 1 pattern(s) tried: ['project/users/(?P<user_id>[0-9]+)/$']
- function inside function is not working in django