stumped by WSGI module import errors

I'm writing a bare bones Python wsgi application and am getting stumped by module import errors. I have a .py file in the current directory which initially failed to import. By adding

sys.path.insert(0, '/Users/guhar/Sites/acom')

the import of the module worked. But I now try and import a module that I had installed via easy_install and it fails to import. I tried setting

sys.path.insert(0, '/Library/Python/2.5/site-packages/')

which contains the egg file, but to no avail. I would've thought that all packages under "/Library/Python/2.5/site-packages/" would be available to a WSGI application.

Does anybody have any pointers?




You cant simply add Python module directories containing .pth files into sys.path. You must use site.addsitedir() or use other options of mod_wsgi to have it use the virtual environment.

I think though perhaps, given that it looks like you are using MacOS X, that you have installed a second installation of Python and whatever mod_wsgi is using is not the version you have installed your packages into. That or your second Python installation is broken which often can be the case on MacOS X.

BTW, I am assuming that when you say WSGI you actually mean mod_wsgi given the tag you used. If you do, please do not use WSGI to refer to mod_wsgi. WSGI is a specification only, mod_wsgi is a specific hosting implementation. You should not be using the terms interchangeably.


If you're running under Apache mod_wsgi, specify all necessary python paths in your virtual host configuration like this:

WSGIDaemonProcess ... python-path=/srv/lala/www:/srv/lala/lib/python2.6/site-packages:/Library/Python/2.5/site-packages


  • Unable to install pyenchant-1.6.5 for python 2.7 on Mac OSX Lion
  • how to convert this date string to “2011-02-15T12:00+00:00” python datetime object
  • python function to set accuracy of float
  • Easy Way to Get Averages Based on Names in List
  • LyX — Title, Abstract, Keywords Missing When Using Elsevier Class in View
  • How do I install a previous version of build tools in addition to the sdk?
  • maven-dependency-plugin ignores outputDirectory configuration
  • How can I determine if process is 32 or 64Bit from a handle?
  • Can't find cygwin setup.exe file?
  • object play not found in scala application
  • Unable to set a breakpoint on main while debugging a program compiled with Rust 1.10 with GDB
  • Implementing Oracle.Web.dll, Oracle.DataAccess.dll 64-bit failed on Windows Server 2008 with IIS 7.5
  • date format change with DT and shiny
  • How secure are apple APNS push notifications?
  • RegistryKey.GetSubKeyNames returns names that are not in that subkey!
  • ASPNetCore MVC Routing Let Server Handle Specific Route
  • Is there a Windows socket API call / option to “block” a range of ports à la SO_EXCLUSIVEADDRUSE
  • Bad interaction between Zope2 XML-RPC and AT Image mutator?
  • Getting short path in python
  • Why are YouTube videos using 'youtube.com/v' not loading
  • Clear fused location provider's location for testing
  • npm 5.4.1 install/uninstall all failing
  • Web.config system.webserver errors
  • How do I configure context broker accept post requests from my remote sensor?
  • WPF - CanExecute dosn't fire when raising Commands from a UserControl
  • Combining SpatialPolygonsDataFrame of two neighbour countries
  • OpenGL 3.3 on Mac OSX El Capitan with LWJGL
  • The plugin 'org.apache.maven.plugins:maven-jboss-as-plugin' does not exist or no valid ver
  • Does CUDA 5 support STL or THRUST inside the device code?
  • Running a C# exe file
  • How to handle AllServersUnavailable Exception
  • Can I make an Android app that runs a web view in Chrome 39?
  • 'TypeError' while using NSGA2 to solve Multi-objective prob. from pyopt-sparse in OpenMDAO
  • Updated Ionic CLI but shows previous version (Windows)
  • Why winpcap requires both .lib and .dll to run?
  • log4net write single file for each call to log.info
  • How get height of the a view with gone visibility and height defined as wrap_content in xml?
  • Exception on Android 4.0 `android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode)`
  • Linking SubReports Without LinkChild/LinkMaster
  • reshape alternating columns in less time and using less memory