0
python 스크립트로 내 모델을 가져 오면 로컬 호스트 서버를 실행할 때 에로 r을 읽었지만 모두 읽었습니다. 시도는 실패했다 :Django는 Python 스크립트에서 모델을 가져온 후에 설정을 가져올 수 없습니다.
[email protected]_VM2:~/env_Compass4D/Compass4D$ python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 9, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 261, in fetch_command
commands = get_commands()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 107, in get_commands
apps = settings.INSTALLED_APPS
File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 54, in __getattr__
self._setup(name)
File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 49, in _setup
self._wrapped = Settings(settings_module)
File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 132, in __init__
% (self.SETTINGS_MODULE, e)
ImportError: Could not import settings 'Compass4D.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named Compass4D.settings
내 sys.path에 :
>>> import sys
>>> print sys.path
['', '/usr/lib/pymodules/python2.7', '/usr/local/lib/python2.7/site-packages', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/python2.7/dist-packages/gst-0.10', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/python2.7/dist-packages/ubuntu-sso-client', '/usr/lib/python2.7/dist-packages/ubuntuone-client', '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel', '/usr/lib/python2.7/dist-packages/ubuntuone-couch', '/usr/lib/python2.7/dist-packages/ubuntuone-installer', '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol']
manage.py :
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Compass4D.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
wsgi.py : 당신의 도움에 대한
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Compass4D.settings")
# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
감사합니다!
음, sys.path에 설정이있는 폴더가 있습니까? 나는 거기에서 그것을 보지 못했다. – Lucas03
sys.path.insert (1, 'env_Compass4D/Compass4D/settings.py') >>> print sys.path [ '', 'env_Compass4D/Compass4D/settings.py', ...] – Datex2
오류입니다. 여전히 거기에, 그리고 내가 파이썬 콘솔을 닫으면 sys 경로는 내가 이전에 삽입 한 경로없이 복원된다 – Datex2