使用Pipenv启动服务器时Django导入错误

时间:2019-05-23 11:46:17

标签: python django windows python-3.7 pipenv

我正在尝试为Windows上的django应用程序运行服务器。我以前是通过Anaconda来做的,但是昨天我将它重新安装到Anaconda3上,在启动pipenv shell,然后启动runserver之后,出现此错误。

Traceback (most recent call last):
  File "manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
  File "C:\Users\norchi\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\django\__init__.py", line 1, in <module>
    from django.utils.version import get_version
  File "C:\Users\norchi\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\django\utils\version.py", line 1, in <module>
    import datetime
ModuleNotFoundError: No module named 'datetime'

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?

这是我尝试过的一些事情:

  • 我尝试更新PATH变量,还添加了PYTHONPATH = C:\ Users \ norchi \ AppData \ Local \ Programs \ Python \ Python37-32

  • 我在虚拟环境之外使用pipenv和pip安装了django。

  • python show django输出django的路径为C:\ Users \ norchi \ AppData \ Local \ Programs \ Python \ Python37-32 \ Lib \ site-packages

0 个答案:

没有答案