I am a very new pyramid learner, I just followed the documentation for creating a new pyramid project : I succeeded to install a virtualenv with pyramid 1.5 packages and run the project in developement mode with 'pserve'.
But, when using apache + mod_wsgi, this is another story : I got this error into the apache error log :
[Fri May 02 09:08:53 2014] [error] [client 127.0.0.1] File "/home/eric/perso/projects/Pyratest/pyramid.wsgi", line 8, in <module>
[Fri May 02 09:08:53 2014] [error] [client 127.0.0.1] from pyramid.paster import get_app, setup_logging
...
[Fri May 02 09:08:53 2014] [error] [client 127.0.0.1] File "/home/eric/perso/projects/venv/local/lib/python2.7/site-packages/pyramid-1.5-py2.7.egg/pyramid/threadlocal.py", line 3, in <module>
[Fri May 02 09:08:53 2014] [error] [client 127.0.0.1] from pyramid.registry import global_registry
[Fri May 02 09:08:53 2014] [error] [client 127.0.0.1] File "/home/eric/perso/projects/venv/local/lib/python2.7/site-packages/pyramid-1.5-py2.7.egg/pyramid/registry.py", line 5, in <module>
[Fri May 02 09:08:53 2014] [error] [client 127.0.0.1] from zope.interface.registry import Components
[Fri May 02 09:08:53 2014] [error] [client 127.0.0.1] ImportError: No module named registry
I added a sys.path dump into my pyramid.wsgi :
import sys
print "=" * 80
for p in sys.path:
print p
from pyramid.paster import get_app, setup_logging
ini_path = '/home/eric/perso/projects/Pyratest/production.ini'
setup_logging(ini_path)
application = get_app(ini_path, 'main')
I can see that the path to zope/interface/registry.py is reachable for the apache user.
This path is at the very beginning of the sys.path, so there should not have a path conflict somewhere.
My apache virtualhost definition :
Listen 9999
NameVirtualHost localhost:9999
<VirtualHost localhost:9999>
ServerAdmin webmaster@localhost
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
ErrorLog /var/log/apache2/pyramid-test-error.log
LogLevel warn
CustomLog /var/log/apache2/pyramid-test-access.log combined
ServerSignature On
Alias /static/ /home/eric/perso/projects/Pyratest/pyratest/static/
<Location "/static/">
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/javascript
</IfModule>
Options Indexes FollowSymLinks MultiViews
Order allow,deny
allow from all
</Location>
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
WSGIDaemonProcess pyramid-test user=eric group=eric processes=4 threads=1 python-path=/home/eric/perso/projects/Pyratest/:/home/eric/perso/projects/venv/lib/python2.7/site-packages
WSGIProcessGroup pyramid-test
WSGIScriptAlias / /home/eric/perso/projects/Pyratest/pyramid.wsgi
<Directory /home/eric/perso/projects/venv>
WSGIProcessGroup eric
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
When I run manually the venv python interpreter, I can import zope.interface.registry without any problem. I do not understand why with mod_wsgi, it does not work.
I tried many times, by creating many venv and populating by using easy_install only or pip only, with or without --no-site-packages, I have taken the latest version of virtualenv,distribute,pip, setuptools, but still the same problem. Only one constant : only zope.interface.registry seems to be unreachable : why this one and not other pyramid packages ?
UPDATE 1 : The registry.py and .pyc are readable :
eric@pcubuntu:~/perso/projects$ . ./venv/bin/activate
(venv)eric@pcubuntu:~/perso/projects$ python
Python 2.7.3 (default, Aug 1 2012, 05:14:39)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import zope.interface.registry
>>> print zope.interface.registry.__file__
/home/eric/perso/projects/venv/lib/python2.7/site-packages/zope.interface-4.1.1-py2.7-linux-x86_64.egg/zope/interface/registry.pyc
>>>
(venv)eric@pcubuntu:~/perso/projects$ ls /home/eric/perso/projects/venv/lib/python2.7/site-packages/zope.interface-4.1.1-py2.7-linux-x86_64.egg/zope/interface/registry.pyc
/home/eric/perso/projects/venv/lib/python2.7/site-packages/zope.interface-4.1.1-py2.7-linux-x86_64.egg/zope/interface/registry.pyc
(venv)eric@pcubuntu:~/perso/projects$ ls -la /home/eric/perso/projects/venv/lib/python2.7/site-packages/zope.interface-4.1.1-py2.7-linux-x86_64.egg/zope/interface/registry.pyc
-rw-rw-r-- 1 eric eric 25127 mai 2 08:54 /home/eric/perso/projects/venv/lib/python2.7/site-packages/zope.interface-4.1.1-py2.7-linux-x86_64.egg/zope/interface/registry.pyc
(venv)eric@pcubuntu:~/perso/projects$ ls -la /home/eric/perso/projects/venv/lib/python2.7/site-packages/zope.interface-4.1.1-py2.7-linux-x86_64.egg/zope/interface/registry.py
-rw-rw-r-- 1 eric eric 18877 mai 2 08:54 /home/eric/perso/projects/venv/lib/python2.7/site-packages/zope.interface-4.1.1-py2.7-linux-x86_64.egg/zope/interface/registry.py
Update 2: here are the installed packages :
(venv)eric@pcubuntu:~/perso/projects/venv$ pip freeze
Chameleon==2.15
Mako==0.9.1
MarkupSafe==0.21
PasteDeploy==1.5.2
Pygments==1.6
Pyratest==0.0
WebOb==1.3.1
argparse==1.2.1
pyramid==1.5
pyramid-chameleon==0.1
pyramid-debugtoolbar==2.0.2
pyramid-mako==1.0.2
repoze.lru==0.6
translationstring==1.1
venusian==1.0a8
waitress==0.8.8
wsgiref==0.1.2
zope.deprecation==4.1.1
zope.interface==4.1.1
Update 3 : I finally found a way to start pyramid, but it is so weird that I cannot consider that as a solution :
- use pip install instead of easy_install
- add "import pip" at the top of the pyramid.wsgi file (!!!)
Update 4 : I Redo the exact procedure of the documentation here Running a Pyramid Application under mod_wsgi, that is : a modwsgi directory, a virtualenv within and finally Pyratest within virtualenv : still the same thing : does not work with apache mod_wsgi : ImportError: No module named registry
Update 5 : I decided to install from scratch a brand new ubuntu 12.04 by using vagrant, by this way, everything is working fine. So the question is why it does not work on my usual desktops : for both, it does not work... I run Django on them without any problem, may be there are some tunings that conflict with pyramid...