当我键入
python manage.py runserver
在Windows powershell上,django服务器正常工作,但是当我尝试在pycharm上运行django服务器时,服务器未连接并给出此错误
Traceback (most recent call last):
File "manage.py", line 10, in main
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 21, in <module>
main()
File "manage.py", line 16, in main
) 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?
。如何解决此错误?
这是快照https://i.stack.imgur.com/dEzUW.png
答案 0 :(得分:1)
pycharm上的python版本是否与您在powershell中使用的版本相同?
在powershell中运行python --version
并转到
文件->设置
首选项->项目解释器-> Python解释器
在PyCharm上,并确保它们相同。