Unable To Load A Python Package Via A File
Solution 1:
Your problem is likely going to be because mod_wsgi is compiled for and bound to a different Python version/installation than you intend to use. It therefore isn't looking at the spot where you installed all your packages.
What Python version are you wanting to use and what do you get for:
import sys
print(sys.version_info)
print(sys.prefix)
when running that from the interpreter.
Then work out what version of Python mod_wsgi is using:
- https://code.google.com/p/modwsgi/wiki/CheckingYourInstallation#Python_Shared_Library
- https://code.google.com/p/modwsgi/wiki/CheckingYourInstallation#Python_Installation_In_Use
UPDATE 1
To check where the django
module is coming from normally from command line Python, so you can see whether you are using the same Python installation as mod_wsgi is compiled for and using, you would in the interpreter do:
>>> import django
>>> print django.__file__
/some/path/lib/python2.7/site-packages/django/__init__.pyc
Modules should have the __file__
attribute, with the exception of builtin modules which are static linked into the Python binary.
So the django
module must have one.
Solution 2:
Your are probably loading the /opt/graphite/conf/graphite.wsgi
through a webserver or something. Can you show us what you do when you get this error.
Have you checked /opt/graphite/conf/graphite.wsgi
is executable ?
chmod +x /opt/graphite/conf/graphite.wsgi
The import of import django.core.handlers.wsgi
is working fine. But thats not where the error is located. The actual error is, that whatever you are using cannot load the file /opt/graphite/conf/graphite.wsgi
as python module not any django module.
Solution 3:
Being new to Python but having recently done battle with Netbeans trying to figure out why a java module was loading wrong, I learned that multiple java versions exist on my Ubuntu 14.04 box. For example, ~$ whereis python -- told me of multiple locations ~$ which python -- gave me /usr/bin/python
So, could your IDE be using a different python? One that, in the terminal, finds the path but not in the IDE?
Post a Comment for "Unable To Load A Python Package Via A File"