I'm very hesistant to take up more of your time on this problem, since
installing straight into Apache works fine and it's not essential that I
use Canopy. So don't persist for my sake, but I'm happy to keep testing
things if you think it's worth getting to the bottom of. (I've ended up
with Canopy through historical accident, as that's how I was introduced to
Python, and have a couple of web apps that are using Canopy virtual
environments. I'm now reconsidering this setup.)
The WSGIPythonHome directive is indeed the same as the sys.prefix
(~/Library/Enthought/Canopy_64bit/User).
When I set the environment variable PYTHONHOME to this path, python won't
start at all: I get the error "ImportError: No module named site". This is
not the case when I set PYTHONHOME
to
/Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/
Where I can get mod_wsgi-express to start (either by not setting PYTHONHOME
or by setting it to the path above), I get an error when an import of
*mod_wsgi.server* is attempted in *handler.wsgi*. The log file says
"ImportError: No module named server".
If I print out sys.path before this import statement, I see the following:
['/private/tmp/mod_wsgi-localhost:8000:502'
'/Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/lib/python27.zip'
'/Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/lib/python2.7'
'/Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/lib/python2.7/plat-darwin'
'/Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/lib/python2.7/plat-mac'
'/Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/lib/python2.7/plat-mac/lib-scriptpackages'
'/Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/lib/python2.7/lib-tk'
'/Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/lib/python2.7/lib-old'
'/Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/lib/python2.7/lib-dynload'
'/Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/lib/python2.7/site-packages']
At the risk of exposing my ignorance, I thought that modifying sys.path
such that it matches what I'd normally see in Canopy might help, so with
sys.path.insert() and sys.path.extend(), I updated sys.path before import
to be:
['/private/tmp/mod_wsgi-localhost:8000:502'
'/Users/sgg/Library/Enthought/Canopy_64bit/User/bin'
'/Users/sgg/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/mod_wsgi-4.5.2-py2.7-macosx-10.6-x86_64.egg'
'/Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/lib/python27.zip'
'/Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/lib/python2.7'
'/Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/lib/python2.7/plat-darwin'
'/Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/lib/python2.7/plat-mac'
'/Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/lib/python2.7/plat-mac/lib-scriptpackages'
'/Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/lib/python2.7/lib-tk'
'/Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/lib/python2.7/lib-old'
'/Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/lib/python2.7/lib-dynload'
'/Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/lib/python2.7/site-packages'
'/Users/sgg/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages'
'/Applications/Canopy.app/appdata/canopy-1.6.2.3262.macosx-x86_64/Canopy.app/Contents/lib/python2.7/site-packages'
'/Users/sgg/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/extensions'
'/Users/sgg/.ipython']
...but I get the same import error. The third path in that list is where
mod_wsgi is installed.
tree -d
~/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/mod_wsgi-4.5.2-py2.7-macosx-10.6-x86_64.egg
├── EGG-INFO
└── mod_wsgi
├── docs
├── images
└── server
└── management
└── commands
In the past, I've found it necessary to add sys.path.insert(1, '
*<virtual_environment_dir>*/lib/python2.7/site-packages')) to my wsgi
files, but this hasn't helped here.
Thanks,
Stephen
On Monday, April 18, 2016 at 2:21:10 AM UTC+1, Graham Dumpleton wrote:
>
> I really hate these third party Python distributions. Don’t know what they
> do to break framework linking.
>
> Even using the install_name_tool tweak, the Python distribution is
> ignoring the WSGIPythonHome directive, presuming that the argument to that
> is the same as sys.prefix you get for that Python when run from command
> line.
>
> That directive should be triggering a Python C API call
> of Py_SetPythonHome() which sets the PYTHONHOME. What it is given should be
> used unless they have mucked around with the Python initialisation sequence.
>
> What do you get if you set:
>
> export PYTHONHOME=$HOME/Library/Enthought/Canopy_64bit/User
>
> before running mod_wsgi-express.
>
> Presuming again that is the value of sys.prefix.
>
> BTW, what is the reason you aren’t just using the system Python version?
>
> Graham
>
--
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.