问题原因:

        问题一:

(djangos) C:\Users\Administrator\django02>python manage.py 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?

        问题二:

(djangos) C:\Users\Administrator\django02>python manage.py xxx 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?

问题分析:

       一、两个问题都是同个问题,都称:“无法导入Django。您确定它已安装并在您的PYTHONPATH环境变量上可用吗?你忘记激活虚拟环境了吗?”

        二、说明在我们这个虚拟环境里并没有django模块,那我们试试pip list看看是否存在,经查看是不存在的。

 

 

问题解决方案:

        一、那竟然没有django这个模块,我们就在这里pip install django 是不是能够安装成功并且解决问题。果然安装后,在我们的虚拟环境中有了这个模块。

 

        二、到此困惑已久的问题就解决了

尾语:      

         这同样也是本人困惑已久的问题,在此站甚至某度翻了许久都未能解决,一发现问题原因和解决办法立马与大家分享,望能给大家有所帮助,有所帮助就一键三连吧。

        这是因何而起呢,具体我也不细究了,头大,脑瓜疼。大概是环境变量问题,可以试试添加环境变量后是否能改善。