My setup is: - Mac OS running pyenv installed with homebrew.
- python 3.6.5 virtualenv - pip install Django==2.0.6
Here is the command I issued and the output. The only answers I've found when I search for this assume an existing django project, and incorrect configuration. I am unable to get to the point of creating the project.
$ django-admin startproject justatestproj
Traceback (most recent call last):
File "/Users/rsquire/.pyenv/versions/forever7pi/bin/django-admin", line 11, in <module>
sys.exit(execute_from_command_line())
File "/Users/rsquire/.pyenv/versions/3.6.5/envs/forever7pi/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/Users/rsquire/.pyenv/versions/3.6.5/envs/forever7pi/lib/python3.6/site-packages/django/core/management/__init__.py", line 317, in execute
settings.INSTALLED_APPS
File "/Users/rsquire/.pyenv/versions/3.6.5/envs/forever7pi/lib/python3.6/site-packages/django/conf/__init__.py", line 56, in __getattr__
self._setup(name)
File "/Users/rsquire/.pyenv/versions/3.6.5/envs/forever7pi/lib/python3.6/site-packages/django/conf/__init__.py", line 43, in _setup
self._wrapped = Settings(settings_module)
File "/Users/rsquire/.pyenv/versions/3.6.5/envs/forever7pi/lib/python3.6/site-packages/django/conf/__init__.py", line 106, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/Users/rsquire/.pyenv/versions/3.6.5/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'config'
Incidentally, I get the same error when I try:
python -m django --version
However, the following works:
$ python
Python 3.6.5 (default, Apr 26 2018, 11:45:15)
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> print(django.get_version())
2.0.6
Any suggestions are much appreciated!
Check if the environment variable DJANGO_SETTINGS_MODULE
is set and unset it if it is. Eg in bash
$ unset DJANGO_SETTINGS_MODULE
对于 Windows 用户,请在命令行上尝试此操作:
set DJANGO_SETTINGS_MODULE=
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.