ModuleNotFoundError:使用mkproject创建项目时,没有名为“ django”的模块

时间:2019-03-06 18:07:37

标签: python django virtualenvwrapper

我正在尝试使用virtualenvwrapper创建一个django项目。我已经安装了virtualenvwrappervirtualenvwrapper.django模板。但是,每当我尝试使用mkproject命令创建django项目时,都会出现标题中提到的错误。这是我的终端输出:

$ mkproject -t django todolist
Using base prefix '/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7'
New python executable in /Users/tanmay/.virtualenvs/todolist/bin/python3.7
Not overwriting existing python script /Users/tanmay/.virtualenvs/todolist/bin/python (you must use /Users/tanmay/.virtualenvs/todolist/bin/python3.7)
Installing setuptools, pip, wheel...
done.
virtualenvwrapper_cd:cd:6: no such file or directory: /Users/tanmay/django-code/todolist
Creating /Users/tanmay/django-code/todolist
Setting project for todolist to /Users/tanmay/django-code/todolist

Applying template  django
Requirement already satisfied: django in /Users/tanmay/.virtualenvs/todolist/lib/python3.7/site-packages (2.1.7)
Requirement already satisfied: pytz in /Users/tanmay/.virtualenvs/todolist/lib/python3.7/site-packages (from django) (2018.9)
virtualenvwrapper.django Running "django-admin.py startproject todolist"
Traceback (most recent call last):
  File "/Users/tanmay/.virtualenvs/todolist/bin/django-admin.py", line 2, in <module>
    from django.core import management
ModuleNotFoundError: No module named 'django'
(todolist) ➜  todolist python
Python 3.7.0 (default, Oct  2 2018, 09:18:58)
[Clang 10.0.0 (clang-1000.11.45.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from django import get_version
>>> get_version()
'2.1.7'

该环境中的pip软件包列表:

(todolist) ➜  todolist pip list
Package    Version
---------- -------
Django     2.1.7
pip        19.0.3
pytz       2018.9
setuptools 40.8.0
wheel      0.33.1

如您所见,Django已安装。另外,当我尝试在该环境下手动创建django项目时,也会收到相同的消息:

(todolist) ➜  django-code django-admin startproject mysite
Traceback (most recent call last):
  File "/Users/tanmay/.virtualenvs/todolist/bin/django-admin", line 6, in <module>
    from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'

我在做什么错了?

0 个答案:

没有答案