This question already has an answer here:
这个问题在这里已有答案:
- ImportError: Couldn't import Django 5 answers
ImportError:无法导入Django 5答案
I am using ubuntu 16.04. Now I am starting my first Django project. Please check this error:
我使用的是ubuntu 16.04。现在我开始我的第一个Django项目。请检查此错误:
(unix-9PXH2taC) unix@unix:~/Desktop/django/test_project$** python manage.py runserver
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'
The above exception was the direct cause of the following exception:
上述异常是以下异常的直接原因:
Traceback (most recent call last):
File "manage.py", line 14, in <module>
) from exc
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?
What is going wrong?
出了什么问题?
1 个解决方案
#1
0
How did you install it ?
你是怎么安装的?
For pip and conda, check if you are in correct environment.
对于pip和conda,请检查您是否处于正确的环境中。
If you did an apt install (or apt-get install), the PYTHONPATH is not reflected until you source .bashrc in your home directory. Log-out and log-in (or type source ~/.bashrc in your terminal).
如果你进行了apt安装(或apt-get安装),那么直到你在主目录中输出.bashrc才会反映出PYTHONPATH。注销和登录(或在终端中输入source~ / .bashrc)。
#1
0
How did you install it ?
你是怎么安装的?
For pip and conda, check if you are in correct environment.
对于pip和conda,请检查您是否处于正确的环境中。
If you did an apt install (or apt-get install), the PYTHONPATH is not reflected until you source .bashrc in your home directory. Log-out and log-in (or type source ~/.bashrc in your terminal).
如果你进行了apt安装(或apt-get安装),那么直到你在主目录中输出.bashrc才会反映出PYTHONPATH。注销和登录(或在终端中输入source~ / .bashrc)。