我有两个Python VE,其中我创建了一个位于桌面上的Django项目。我最近创建了另一个VE来启动另一个Django项目。但是,当我在新的VE中运行django-admin startproject projectname
时,我得到一个ImportError,说明无法导入另一个Django应用程序。
尝试导入旧应用程序的内容是什么?为什么会发生这种情况?
我在Debian 8上运行Django 1.9。
Traceback (most recent call last):
File "/home/lie/.virtualenvs/tagger/bin/django-admin", line 11, in <module>
sys.exit(execute_from_command_line())
File "/home/lie/.virtualenvs/tagger/lib/python3.4/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
utility.execute()
File "/home/lie/.virtualenvs/tagger/lib/python3.4/site-packages/django/core/management/__init__.py", line 302, in execute
settings.INSTALLED_APPS
File "/home/lie/.virtualenvs/tagger/lib/python3.4/site-packages/django/conf/__init__.py", line 55, in __getattr__
self._setup(name)
File "/home/lie/.virtualenvs/tagger/lib/python3.4/site-packages/django/conf/__init__.py", line 43, in _setup
self._wrapped = Settings(settings_module)
File "/home/lie/.virtualenvs/tagger/lib/python3.4/site-packages/django/conf/__init__.py", line 99, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/home/lie/.virtualenvs/tagger/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2212, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked
ImportError: No module named 'AUVSIDataProc'
答案 0 :(得分:3)
我发现有一个名为DJANGO_SETTINGS_MODULE
的环境变量。
我刚刚解开它:export DJANGO_SETTINGS_MODULE=""
。我能够开始一个新项目。