简体   繁体   中英

ImportError: No module named 'django', ImportError: Couldn't import Django

I'm new to python, when I run this command I'm getting this error

plutus@plutus-probook /var/www/html/python_learn/myproject $ python manage.py startapp webapp
Traceback (most recent call last):
  File "manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
ImportError: No module named 'django'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    import django
ImportError: No module named 'django'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 17, in <module>
    "Couldn't import Django. Are you sure it's installed and "
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?

If I try to install django, then this is the result

plutus@plutus-probook /var/www/html/python_learn/myproject $ pip install django
Requirement already satisfied: django in /usr/local/lib/python2.7/dist-packages (1.11.6)
Requirement already satisfied: pytz in /usr/local/lib/python2.7/dist-packages (from django) (2017.2)

This could be because you might have multiple versions of python and pip lying around . Try this

python -m pip install django

This will make sure you install django for the same python version which is invoked when you call python on the terminal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM