Hi Graham!

I uninstalled mod_wsgi in my virtualenv and used the mod_wsgi sources to 
manually install them. Configuring mod_wsgi with Python 3.5 did the job and 
the URL is now successfully served by Apache. Thank you very much for your 
help!!

Le jeudi 25 février 2016 12:46:52 UTC+1, Graham Dumpleton a écrit :
>
> You will need to uninstall mod_wsgi from your Apache installation and 
> recompile/reinstall mod_wsgi from source code so it is compiled against 
> Python 3.5.
>
> You cannot mix Python versions like you are doing by telling mod_wsgi 
> compiled with Python 3.4 to use Python virtual environment directory of a 
> Python 3.5 version.
>
> BTW. Don’t use python-path to refer to site-packages directory. Better to 
> use python-home option to refer to the root directory for the Python 
> virtual environment.
>
>
> http://blog.dscpl.com.au/2014/09/using-python-virtual-environments-with.html
> http://blog.dscpl.com.au/2014/09/python-module-search-path-and-modwsgi.html
>
> Solve your version mismatch problem first.
>
> Graham
>
> On 25 Feb 2016, at 10:19 PM, Quentin Caron <[email protected] 
> <javascript:>> wrote:
>
> Hi guys!
>
> I have open a thread on Stack Overflow 
> <http://stackoverflow.com/questions/35613336/debian-mod-wsgi-no-module-named-psycopg2-psycopg>
>  
> about my issue but I believe you will be able to help me :) Here is my 
> problem:
>
> I am struggling in making Django run with mod_wsgi. I tried to follow 
> recommendations here 
> <http://stackoverflow.com/questions/21158918/django-mod-wsgi-psycopg2-improperlyconfigured-error-loading-psycopg2-module>
>  but 
> it did not work.
>
> The server is a Debian :
>
> $ lsb_release -da
>     No LSB modules are available.
>     Distributor ID: Debian
>     Description:    Debian GNU/Linux 8.3 (jessie)
>     Release:    8.3
>     Codename:   jessie
>
> Python 3.5.1 has been installed with --ensable-shared. The virtualenv 
> *venv* uses this Python because of the following in the user 
> .bash_profile :
>
> LD_LIBRARY_PATH=/usr/local/lib
> VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3.5
> WORKON_HOME=$HOME/.virtualenvs
> source /usr/local/bin/virtualenvwrapper.sh
>
> *libapache2-mod-wsgi-py3* has been installed, as it is explained, it 
> works for Python3.X. So why do I have a "No module named 
> 'psycopg2._psycopg'" error here ?
>
> *mod_wsgi* has been installed in the virtualenv venv.
>
> Here is the virtualhost:
>
> <VirtualHost *:80>
>     ServerName mysite.com
>     ServerAlias mysite.com
>     ServerAdmin [email protected]
>     DocumentRoot /var/www/mysite.com
>     ErrorLog ${APACHE_LOG_DIR}/error.log
>     CustomLog ${APACHE_LOG_DIR}/access.log combined
>
>     WSGIDaemonProcess api 
> python-path=/var/www/mysite.com:/home/user/.virtualenvs/venv/lib/python3.5/site-packages
>     WSGIProcessGroup api
>     WSGIScriptAlias / /var/www/mysite.com/wsgi.py
>
>     <Directory /var/www/mysite.com>
>         <Files wsgi.py>
>             Require all granted
>         </Files>
>     </Directory></VirtualHost>
>
> Here is the content of my apache error.log file:
>
> mod_wsgi: Compiled for Python/3.4.2rc1+.
> mod_wsgi: Runtime using Python/3.4.2.
> AH00489: Apache/2.4.10 (Debian) mod_wsgi/4.3.0 Python/3.4.2 configured -- 
> resuming normal operations
> AH00094: Command line: '/usr/sbin/apache2'
> mod_wsgi (pid=12796): Target WSGI script '/var/www/mysite.com/wsgi.py' cannot 
> be loaded as Python module.
> mod_wsgi (pid=12796): Exception occurred processing WSGI script 
> '/var/www/mysite.com/wsgi.py'.Traceback (most recent call last):File 
> "/home/user/.virtualenvs/venv/lib/python3.5/site-packages/django/db/backends/postgresql/base.py",
>  line 20, in <module>import psycopg2 as DatabaseFile 
> "/home/user/.virtualenvs/venv/lib/python3.5/site-packages/psycopg2/__init__.py",
>  line 50, in <module>from psycopg2._psycopg import BINARY, NUMBER, STRING, 
> DATETIME, ROWIDImportError: No module named 'psycopg2._psycopg'During 
> handling of the above exception, another exception occurred:Traceback (most 
> recent call last):File "/var/www/mysite.com/wsgi.py", line 18, in <module>
> application = get_wsgi_application()File 
> "/home/user/.virtualenvs/venv/lib/python3.5/site-packages/django/core/wsgi.py",
>  line 13, in get_wsgi_application
> django.setup()File 
> "/home/user/.virtualenvs/venv/lib/python3.5/site-packages/django/__init__.py",
>  line 18, in setup
> apps.populate(settings.INSTALLED_APPS)File 
> "/home/user/.virtualenvs/venv/lib/python3.5/site-packages/django/apps/registry.py",
>  line 108, in populate
> app_config.import_models(all_models)File 
> "/home/user/.virtualenvs/venv/lib/python3.5/site-packages/django/apps/config.py",
>  line 202, in import_models
> self.models_module = import_module(models_module_name)File 
> "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_modulereturn 
> _bootstrap._gcd_import(name[level:], package, level)File "<frozen 
> importlib._bootstrap>", line 2254, in _gcd_importFile "<frozen 
> importlib._bootstrap>", line 2237, in _find_and_loadFile "<frozen 
> importlib._bootstrap>", line 2226, in _find_and_load_unlockedFile "<frozen 
> importlib._bootstrap>", line 1200, in _load_unlockedFile "<frozen 
> importlib._bootstrap>", line 1129, in _execFile "<frozen 
> importlib._bootstrap>", line 1471, in exec_moduleFile "<frozen 
> importlib._bootstrap>", line 321, in _call_with_frames_removedFile 
> "/home/user/.virtualenvs/venv/lib/python3.5/site-packages/django/contrib/auth/models.py",
>  line 4, in <module>from django.contrib.auth.base_user import 
> AbstractBaseUser, BaseUserManagerFile 
> "/home/user/.virtualenvs/venv/lib/python3.5/site-packages/django/contrib/auth/base_user.py",
>  line 49, in <module>class AbstractBaseUser(models.Model):
>    File 
> "/home/user/.virtualenvs/venv/lib/python3.5/site-packages/django/db/models/base.py",
>  line 108, in __new__
>      new_class.add_to_class('_meta', Options(meta, app_label))
>    File 
> "/home/user/.virtualenvs/venv/lib/python3.5/site-packages/django/db/models/base.py",
>  line 299, in add_to_class
>      value.contribute_to_class(cls, name)
>    File 
> "/home/user/.virtualenvs/venv/lib/python3.5/site-packages/django/db/models/options.py",
>  line 263, in contribute_to_class
>      self.db_table = truncate_name(self.db_table, 
> connection.ops.max_name_length())
>    File 
> "/home/user/.virtualenvs/venv/lib/python3.5/site-packages/django/db/__init__.py",
>  line 36, in __getattr__
>      return getattr(connections[DEFAULT_DB_ALIAS], item)
>    File 
> "/home/user/.virtualenvs/venv/lib/python3.5/site-packages/django/db/utils.py",
>  line 212, in __getitem__
>      backend = load_backend(db['ENGINE'])
>    File 
> "/home/user/.virtualenvs/venv/lib/python3.5/site-packages/django/db/utils.py",
>  line 116, in load_backend
>      return import_module('%s.base' % backend_name)
>    File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
>      return _bootstrap._gcd_import(name[level:], package, level)
>    File 
> "/home/user/.virtualenvs/venv/lib/python3.5/site-packages/django/contrib/gis/db/backends/postgis/base.py",
>  line 2,
>
> ...

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.

Reply via email to