[Django] target wsgi script wsgi.py cannot be loaded as python module 에러 해결 방법
[Mon Jan 28 10:55:11.851599 2019] [:error] [pid 1228] [client 10.10.91.70:61336] mod_wsgi (pid=1228): Target WSGI script '[wsgi 파일 경로]/wsgi.py' cannot be loaded as Python module. [Mon Jan 28 10:55:11.851650 2019] [:error] [pid 1228] [client 10.10.91.70:61336] mod_wsgi (pid=1228): Exception occurred processing WSGI script '[wsgi 파일 경로]/wsgi.py'. [Mon Jan 28 10:55:11.851685 2019] [:error] [pid 1228] [client 10.10.91.70:61336] Traceback (most recent call last): [Mon Jan 28 10:55:11.851705 2019] [:error] [pid 1228] [client 10.10.91.70:61336] File "wsgi.py", line 16, in[Mon Jan 28 10:55:11.851776 2019] [:error] [pid 1228] [client 10.10.91.70:61336] application = get_wsgi_application() [Mon Jan 28 10:55:11.851788 2019] [:error] [pid 1228] [client 10.10.91.70:61336] File "/usr/lib/python2.7/site-packages/Django-1.9.13-py2.7.egg/django/core/wsgi.py", line 13, in get_wsgi_application [Mon Jan 28 10:55:11.875171 2019] [:error] [pid 1228] [client 10.10.91.70:61336] django.setup() [Mon Jan 28 10:55:11.875195 2019] [:error] [pid 1228] [client 10.10.91.70:61336] File "/usr/lib/python2.7/site-packages/Django-1.9.13-py2.7.egg/django/__init__.py", line 17, in setup [Mon Jan 28 10:55:11.901613 2019] [:error] [pid 1228] [client 10.10.91.70:61336] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) [Mon Jan 28 10:55:11.901635 2019] [:error] [pid 1228] [client 10.10.91.70:61336] File "/usr/lib/python2.7/site-packages/Django-1.9.13-py2.7.egg/django/conf/__init__.py", line 55, in __getattr__ [Mon Jan 28 10:55:11.911413 2019] [:error] [pid 1228] [client 10.10.91.70:61336] self._setup(name) [Mon Jan 28 10:55:11.911458 2019] [:error] [pid 1228] [client 10.10.91.70:61336] File "/usr/lib/python2.7/site-packages/Django-1.9.13-py2.7.egg/django/conf/__init__.py", line 43, in _setup [Mon Jan 28 10:55:11.911503 2019] [:error] [pid 1228] [client 10.10.91.70:61336] self._wrapped = Settings(settings_module) [Mon Jan 28 10:55:11.911512 2019] [:error] [pid 1228] [client 10.10.91.70:61336] File "/usr/lib/python2.7/site-packages/Django-1.9.13-py2.7.egg/django/conf/__init__.py", line 99, in __init__ [Mon Jan 28 10:55:11.911527 2019] [:error] [pid 1228] [client 10.10.91.70:61336] mod = importlib.import_module(self.SETTINGS_MODULE) [Mon Jan 28 10:55:11.911536 2019] [:error] [pid 1228] [client 10.10.91.70:61336] File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module [Mon Jan 28 10:55:11.938176 2019] [:error] [pid 1228] [client 10.10.91.70:61336] __import__(name) [Mon Jan 28 10:55:11.938241 2019] [:error] [pid 1228] [client 10.10.91.70:61336] ImportError: No module named [프로젝트명].settings
""" WSGI config for VersionMoving project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/ """ import os import site import sys import posixpath from django.core.wsgi import get_wsgi_application import django.core.handlers.wsgi # -- site-packages 추가 site.addsitedir('/virtualenvs/myprojectenv/python2.7/lib/site-packages') # 절대 경로 """ # 상대 경로로 입력하고 싶은 경우 site.addsitedir(os.path.expanduser("~/.virtualenvs/myprojectenv/python2.7/lib/site-packages")) """ # -- Virtualenv 실행 ( activate ) activate_env=os.path.expanduser("~/.virtualenvs/myprojectenv/bin/activate_this.py") execfile(activate_env, dict(__file__=activate_env)) # -- 프로젝트폴더 내 경로 추가 path = '/www/html/django/프로젝트폴더" # 절대 경로 if path not in sys.path: sys.path.append(path) sys.stdout = sys.stderr # -- django wsgi 핸들러 선언 _application = django.core.handlers.wsgi.WSGIHandler() # -- scripts 폴더 설정 def application(environ, start_response): # Wrapper to set SCRIPT_NAME to actual mount point. environ['SCRIPT_NAME'] = posixpath.dirname(environ['SCRIPT_NAME']) if environ['SCRIPT_NAME'] == '/': environ['SCRIPT_NAME'] = '' return _application(environ, start_response) # -- 환경변수 Django_settings_module 에 settings 파일 설정. os.environ['DJANGO_SETTINGS_MODULE'] = '[프로젝트명].settings' application = get_wsgi_application()
'Python > Django' 카테고리의 다른 글
[Django] Vue.js 사용하기 (1) | 2019.06.05 |
---|---|
[Django] Database 테이블에 데이터가 없을 때 만 추가하는 방법 (0) | 2019.01.31 |
[Django] 사용자 인증 시스템 (0) | 2019.01.23 |
[Django] 사용자 인증 시스템 (2) (0) | 2019.01.23 |
[Django] 데이터베이스에 초기(initial) 데이터 입력방법 (0) | 2019.01.22 |