Question

I am working on setting up the pyramid framework on python3.3 virtual env. For the database connection I use MySQL Connector/Python (SQLAlchemy).

I came across with the problem:

When I try to select records form the database I get the following:

[Wed Feb 12 09:20:34.373204 2014] [:error] [pid 29351] [remote 127.0.0.1:55376] File "/home/xxx/wsgi/env/lib/python3.3/site-packages/mysql_connector_python-1.1.5-py3.3.egg/mysql/connector/pooling.py", line 29, in <module> [Wed Feb 12 09:20:34.373237 2014] [:error] [pid 29351] [remote 127.0.0.1:55376]
ImportError: No module named queue

It can't find the module queue, but this works just fine:

~/wsgi/env$ bin/python3.3 
Python 3.3.2+ (default, Oct  9 2013, 14:50:09) 
[GCC 4.8.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import queue
>>> 

Where is the problem? There are no symlink in wsgi/env/lib/python3.3/ for queue.py, but if I add it manually, the error still appears

EDIT 1: When I use the pserve command to launch a web server, everything is ok, but with apache2, the one above happens.

Apache config:

# Use only 1 Python sub-interpreter.  Multiple sub-interpreters
# play badly with C extensions.  See
# http://stackoverflow.com/a/10558360/209039
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
WSGIDaemonProcess pyramid user=user group=staff threads=4 \
   python-path=/home/user/wsgi/env/lib/python3.3/site-packages
WSGIScriptAlias /app /home/user/wsgi/env/pyramid.wsgi

<Directory /home/user/wsgi/env>
  WSGIProcessGroup pyramid
 # Order allow,deny
  Require all granted
</Directory>
Was it helpful?

Solution

Found out what caused all the problems. I was using mod_wsgi, not compatible with python3.3. Solved the problem with:

sudo apt-get install libapache2-mod-wsgi-py3

OTHER TIPS

Short story: If your Python3-code relies on the queue-module make sure to import "queue" - not "Queue".

Long story: I was experiencing a similar issue, while trying to get an automatic restart of my apache-served wsgi-coupled django-application. In my case i took the code sample from https://code.google.com/p/modwsgi/wiki/ReloadingSourceCode and being still a noob first "solved" my problem with the line "import Queue" by adding "from multiprocessing import Queue" - which was obviously wrong as the code sample was actually trying to import the queue from queuelib-module (at least i think so). So the real and somewhat subtle problem was the big "Q" - changing the line to "import queue" solved the problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top