gpt4 book ai didi

python - django-admin.py startproject 返回无法导入设置 'settings'

转载 作者:行者123 更新时间:2023-11-28 20:05:48 26 4
gpt4 key购买 nike

virtualenv ./env
source ./env/bin/activate
pip install Django
django-admin.py startproject src

我得到一个错误“ImportError: Could not import settings 'settings' (Is it on sys.path? Is there an import error in the settings file?): No module named settings”

我使用 MacO。Python 版本为 2.7.6。

username-Pro:project_1 username$ virtualenv env/
New python executable in env/bin/python
Installing setuptools............done.
Installing pip...............done.
username-Pro:project_1 username$ source env/bin/activate
(env)username-Pro:project_1 username$ pip install -U setuptools pip
Downloading/unpacking setuptools from https://pypi.python.org/packages/source/s/setuptools/setuptools-7.0.tar.gz#md5=6245d6752e2ef803c365f560f7f2f940
Downloading setuptools-7.0.tar.gz (793kB): 793kB downloaded
Running setup.py egg_info for package setuptools

Downloading/unpacking pip from https://pypi.python.org/packages/source/p/pip/pip-1.5.6.tar.gz#md5=01026f87978932060cc86c1dc527903e
Downloading pip-1.5.6.tar.gz (938kB): 938kB downloaded
Running setup.py egg_info for package pip

warning: no files found matching 'pip/cacert.pem'
warning: no files found matching '*.html' under directory 'docs'
warning: no previously-included files matching '*.rst' found under directory 'docs/_build'
no previously-included directories found matching 'docs/_build/_sources'
Installing collected packages: setuptools, pip
Found existing installation: setuptools 0.6c11
Uninstalling setuptools:
Successfully uninstalled setuptools
Running setup.py install for setuptools

Installing easy_install script to /Users/username/Projects/project_1/env/bin
Installing easy_install-2.7 script to /Users/username/Projects/project_1/env/bin
Found existing installation: pip 1.3.1
Uninstalling pip:
Successfully uninstalled pip
Running setup.py install for pip

warning: no files found matching 'pip/cacert.pem'
warning: no files found matching '*.html' under directory 'docs'
warning: no previously-included files matching '*.rst' found under directory 'docs/_build'
no previously-included directories found matching 'docs/_build/_sources'
Installing pip script to /Users/username/Projects/project_1/env/bin
Installing pip2.7 script to /Users/username/Projects/project_1/env/bin
Installing pip2 script to /Users/username/Projects/project_1/env/bin
Successfully installed setuptools pip
Cleaning up...
(env)username-Pro:project_1 username$ pip install Django
Downloading/unpacking Django
Downloading Django-1.7.1-py2.py3-none-any.whl (7.4MB): 7.4MB downloaded
Installing collected packages: Django
Successfully installed Django
Cleaning up...
(env)username-Pro:project_1 username$ python -c "import django; print(django.get_version())"
1.7.1
(env)username-Pro:project_1 username$ django-admin.py startproject src
Traceback (most recent call last):
File "/Users/username/Projects/project_1/env/bin/django-admin.py", line 5, in <module>
management.execute_from_command_line()
File "/Users/username/Projects/project_1/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/Users/username/Projects/project_1/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute
settings.INSTALLED_APPS
File "/Users/username/Projects/project_1/env/lib/python2.7/site-packages/django/conf/__init__.py", line 46, in __getattr__
self._setup(name)
File "/Users/username/Projects/project_1/env/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "/Users/username/Projects/project_1/env/lib/python2.7/site-packages/django/conf/__init__.py", line 98, in __init__
% (self.SETTINGS_MODULE, e)
ImportError: Could not import settings 'settings' (Is it on sys.path? Is there an import error in the settings file?): No module named settings
(env)username-Pro:project_1 username$

最佳答案

您可能有来自以前项目的设置环境变量。

$ unset DJANGO_SETTINGS_MODULE

关于python - django-admin.py startproject 返回无法导入设置 'settings',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27234308/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com