I get the following error when trying to run Django from the command line.
File manage.py, line 8, in <module> from django.core.management import execute_from_command_line ImportError: No module named django.core.management
Any ideas on how to solve this?
management. base BaseCommand Example Code. BaseCommand is a Django object for creating new Django admin commands that can be invoked with the manage.py script. The Django project team as usual provides fantastic documentation for creating your own commands.
The Python "ModuleNotFoundError: No module named 'django'" occurs when we forget to install the Django module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install Django command.
What is Django? Django is a Python framework that makes it easier to create web sites using Python. Django takes care of the difficult stuff so that you can concentrate on building your web applications.
Django can be installed easily using pip . In the command prompt, execute the following command: pip install django . This will download and install Django. After the installation has completed, you can verify your Django installation by executing django-admin --version in the command prompt.
It sounds like you do not have django installed. You should check the directory produced by this command:
python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
To see if you have the django packages in there.
If there's no django folder inside of site-packages, then you do not have django installed (at least for that version of python).
It is possible you have more than one version of python installed and django is inside of another version. You can find out all the versions of python if you type python
and then press TAB. Here are all the different python's I have.
$python python python2-config python2.6 python2.7-config pythonw2.5 python-config python2.5 python2.6-config pythonw pythonw2.6 python2 python2.5-config python2.7 pythonw2 pythonw2.7
You can do the above command for each version of python and look inside the site-packages directory of each to see if any of them have django installed. For example:
python2.5 -c "from distutils.sysconfig import get_python_lib; print get_python_lib()" python2.6 -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
If you happen to find django inside of say python2.6, try your original command with
python2.6 manage.py ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With