Django WSGI deployment. cannot import name 'SimpleCookie' -


i trying deploy django site. runs in development server intended. when running python under cp virtual environment import succeds well.

but under apache mod_wsgi folloing error log site:

[wed jun 10 17:26:20.204238 2015] [:info] [pid 18376:tid 140307600816000] mod_wsgi (pid=18376): attach interpreter ''. [wed jun 10 17:26:47.476066 2015] [:info] [pid 18377:tid 140307470911232] [client 192.168.1.1:15841] mod_wsgi (pid=18377, process='', application='cp'): loading wsgi script '/var/www/django_projects/cp/mysite/wsgi.py'. [wed jun 10 17:26:47.575882 2015] [:error] [pid 18377:tid 140307470911232] [client 192.168.1.1:15841] mod_wsgi (pid=18377): target wsgi script '/var/www/django_projects/cp/mysite/wsgi.py' cannot loaded python module. [wed jun 10 17:26:47.575951 2015] [:error] [pid 18377:tid 140307470911232] [client 192.168.1.1:15841] mod_wsgi (pid=18377): exception occurred processing wsgi script '/var/www/django_projects/cp/mysite/wsgi.py'. [wed jun 10 17:26:47.575996 2015] [:error] [pid 18377:tid 140307470911232] [client 192.168.1.1:15841] traceback (most recent call last): [wed jun 10 17:26:47.576201 2015] [:error] [pid 18377:tid 140307470911232] [client 192.168.1.1:15841]   file "/var/www/django_projects/cp/mysite/wsgi.py", line 23, in <module> [wed jun 10 17:26:47.576209 2015] [:error] [pid 18377:tid 140307470911232] [client 192.168.1.1:15841]     django.core.wsgi import get_wsgi_application [wed jun 10 17:26:47.576319 2015] [:error] [pid 18377:tid 140307470911232] [client 192.168.1.1:15841]   file "/var/www/.virtualenvs/cp/lib/python3.4/site-packages/django/core/wsgi.py", line 2, in <module> [wed jun 10 17:26:47.576327 2015] [:error] [pid 18377:tid 140307470911232] [client 192.168.1.1:15841]     django.core.handlers.wsgi import wsgihandler [wed jun 10 17:26:47.576485 2015] [:error] [pid 18377:tid 140307470911232] [client 192.168.1.1:15841]   file "/var/www/.virtualenvs/cp/lib/python3.4/site-packages/django/core/handlers/wsgi.py", line 11, in <module> [wed jun 10 17:26:47.576493 2015] [:error] [pid 18377:tid 140307470911232] [client 192.168.1.1:15841]     django import http [wed jun 10 17:26:47.576600 2015] [:error] [pid 18377:tid 140307470911232] [client 192.168.1.1:15841]   file "/var/www/.virtualenvs/cp/lib/python3.4/site-packages/django/http/__init__.py", line 1, in <module> [wed jun 10 17:26:47.576608 2015] [:error] [pid 18377:tid 140307470911232] [client 192.168.1.1:15841]     django.http.cookie import simplecookie, parse_cookie [wed jun 10 17:26:47.576738 2015] [:error] [pid 18377:tid 140307470911232] [client 192.168.1.1:15841]   file "/var/www/.virtualenvs/cp/lib/python3.4/site-packages/django/http/cookie.py", line 7, in <module> [wed jun 10 17:26:47.576746 2015] [:error] [pid 18377:tid 140307470911232] [client 192.168.1.1:15841]     django.utils.six.moves import http_cookies [wed jun 10 17:26:47.577075 2015] [:error] [pid 18377:tid 140307470911232] [client 192.168.1.1:15841]   file "/var/www/.virtualenvs/cp/lib/python3.4/site-packages/django/utils/six.py", line 90, in __get__ [wed jun 10 17:26:47.577084 2015] [:error] [pid 18377:tid 140307470911232] [client 192.168.1.1:15841]     result = self._resolve() [wed jun 10 17:26:47.577119 2015] [:error] [pid 18377:tid 140307470911232] [client 192.168.1.1:15841]   file "/var/www/.virtualenvs/cp/lib/python3.4/site-packages/django/utils/six.py", line 113, in _resolve [wed jun 10 17:26:47.577126 2015] [:error] [pid 18377:tid 140307470911232] [client 192.168.1.1:15841]     return _import_module(self.mod) [wed jun 10 17:26:47.577156 2015] [:error] [pid 18377:tid 140307470911232] [client 192.168.1.1:15841]   file "/var/www/.virtualenvs/cp/lib/python3.4/site-packages/django/utils/six.py", line 80, in _import_module [wed jun 10 17:26:47.577163 2015] [:error] [pid 18377:tid 140307470911232] [client 192.168.1.1:15841]     __import__(name) [wed jun 10 17:26:47.577193 2015] [:error] [pid 18377:tid 140307470911232] [client 192.168.1.1:15841]   file "/var/www/.virtualenvs/cp/lib/python3.4/site-packages/django/http/__init__.py", line 1, in <module> [wed jun 10 17:26:47.577200 2015] [:error] [pid 18377:tid 140307470911232] [client 192.168.1.1:15841]     django.http.cookie import simplecookie, parse_cookie [wed jun 10 17:26:47.577228 2015] [:error] [pid 18377:tid 140307470911232] [client 192.168.1.1:15841] importerror: cannot import name 'simplecookie' 

it seems import of simplecookie done correctly first time, throws , error.

my wsgi.py file is:

import os import sys import site  sys.path.insert(0,'/var/www/.virtualenvs/cp/lib/python3.4/site-packages') sys.path.insert(0, '/var/www/.virtualenvs/cp/lib/python3.4/site-packages/django')  # add app's directory pythonpath sys.path.insert(0,'/var/www/django_projects/cp') #sys.path.insert(0,'/var/www/django_projects/cp/mysite')  os.environ['django_settings_module'] = 'mysite.settings'  django.core.wsgi import get_wsgi_application application = get_wsgi_application() 

edit: not understand why, when removing

sys.path.insert(0, '/var/www/.virtualenvs/cp/lib/python3.4/site-packages/django') 

an error changes one:

 django.core.exceptions.improperlyconfigured: error loading either pysqlite2 or sqlite3 modules (tried in order): no module named '_sqlite3' 

seems this solves original error raises new one.

edit2: tried add

exec(open("/var/www/.virtualenvs/cp/bin/activate_this.py").read()) 

before calling get_wsgi_application(), not solve _sqlite3 import error

closing question , open new 1 new error: django wsgi deployment. no module named '_sqlite3'

i have removed unnecessary path insert

sys.path.insert(0, '/var/www/.virtualenvs/cp/lib/python3.4/site-packages/django') 

seems this solves original error.


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -