Django学习笔记(三十九):(BUG)ModuleNotFoundError: No module named 'django'

当执行python manage.py runerver报错如下,说没有找到module named ‘django’

Error Reproduce:
mamerunminmatoMacBook-Pro:learning_log RunMin$ source ll_env/bin/activate
(ll_env) mamerunminmatoMacBook-Pro:learning_log RunMin$ python manage.py migrate
Traceback (most recent call last):
File “manage.py”, line 8, in 
from django.core.management import execute_from_command_line
ModuleNotFoundError: 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 
) 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?
 

综合网上的资料,分析可能的原因:

1,django为安装或者版本较低,这个可能性是最小的,也是一开始就被排除的可能性

2,虚拟环境问题,是否进入虚拟环境,我的这次测试是在本地测试,为涉及到虚拟环境,当之前有在本机进行过虚拟环境的测试,猜测可能有关

3,调用的python环境中是否有django,然后我在我的环境变量中发现,我在环境变量中添加了两个python的路径,一个是虚拟环境的路径(内含python),而且虚拟环境的路径在另一个python环境的前面,优先级高所以调用了那个python。

发现可能是这个原因导致的,我将环境变量中的虚拟环境的路径删除再次执行命令,运行正常

D:\newlife>python manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).

You have 15 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes,
sessions.
Run 'python manage.py migrate' to apply them.
April 11, 2019 - 17:37:11
Django version 1.11.7, using settings 'newlife.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
 

你可能感兴趣的:(Django)