Note that there are some explanatory texts on larger screens.

plurals
  1. PO(Another) ImportError with Flask under mod_wsgi
    primarykey
    data
    text
    <p>Sorry if this seems like a repeat of several previous questions, but none of those have helped me so far :-/</p> <p>I have written a Flask app that I am attempting to deploy under mod_wsgi and apache2.</p> <p>I get the following <code>ImportError</code>:</p> <pre><code>[Tue Apr 23 23:46:56 2013] [info] Server built: Dec 9 2012 18:57:18 [Tue Apr 23 23:46:56 2013] [info] mod_wsgi (pid=7445): Initializing Python. [Tue Apr 23 23:46:56 2013] [info] mod_wsgi (pid=7445): Attach interpreter ''. [Tue Apr 23 23:47:10 2013] [info] [client 127.0.0.1] mod_wsgi (pid=7443, process='foo.com', application=''): Loading WSGI script '/Users/admin/Sites/p4p/p4p_jsapp/pfp/pfp.wsgi'. [Tue Apr 23 23:47:10 2013] [error] [client 127.0.0.1] mod_wsgi (pid=7443): Target WSGI script '/Users/admin/Sites/p4p/p4p_jsapp/pfp/pfp.wsgi' cannot be loaded as Python module. [Tue Apr 23 23:47:10 2013] [error] [client 127.0.0.1] mod_wsgi (pid=7443): Exception occurred processing WSGI script '/Users/admin/Sites/p4p/p4p_jsapp/pfp/pfp.wsgi'. [Tue Apr 23 23:47:10 2013] [error] [client 127.0.0.1] Traceback (most recent call last): [Tue Apr 23 23:47:10 2013] [error] [client 127.0.0.1] File "/Users/admin/Sites/p4p/p4p_jsapp/pfp/pfp.wsgi", line 7, in &lt;module&gt; [Tue Apr 23 23:47:10 2013] [error] [client 127.0.0.1] from PfpServer import app as application [Tue Apr 23 23:47:10 2013] [error] [client 127.0.0.1] File "/Users/admin/Sites/p4p/p4p_jsapp/pfp/PfpServer.py", line 4, in &lt;module&gt; [Tue Apr 23 23:47:10 2013] [error] [client 127.0.0.1] import pandas as pd [Tue Apr 23 23:47:10 2013] [error] [client 127.0.0.1] ImportError: No module named pandas </code></pre> <p>Apache conf:</p> <pre><code>&lt;VirtualHost *:80&gt; ServerName www.foo.com ServerAlias foo.com DocumentRoot /Users/admin/Sites/p4p/p4p_jsapp/www &lt;Directory /Users/admin/Sites/p4p/p4p_jsapp/www&gt; Order allow,deny Allow from all &lt;/Directory&gt; WSGIDaemonProcess foo.com user=admin processes=2 threads=15 display-name=%{GROUP} WSGIProcessGroup foo.com WSGIScriptAlias / /Users/admin/Sites/p4p/p4p_jsapp/pfp/pfp.wsgi &lt;Directory /Users/admin/Sites/p4p/p4p_jsapp/pfp&gt; WSGIProcessGroup foo.com WSGIApplicationGroup %{GLOBAL} Order allow,deny Allow from all &lt;/Directory&gt; &lt;/VirtualHost&gt; </code></pre> <p>pfp.wsgi:</p> <pre><code>import sys activate_this = '/Users/admin/Sites/p4p/p4p_jsapp/foo/bin/activate_this.py' execfile(activate_this, dict(__file__=activate_this)) sys.path.append('/Users/admin/Sites/p4p/p4p_jsapp/pfp') from PfpServer import app as application </code></pre> <p>PfPServer.py:</p> <pre><code>import numpy as np import pandas as pd import ujson from flask import Flask, Response, request, render_template import traceback app = Flask(__name__) # ... </code></pre> <p>I have tried using with and without virtualenv to see if that would help, but I get the same error regardless. What's the problem here?</p> <p>edit: just to make it totally clear, I have pandas installed and the app runs fine locally in the debugger </p> <p>edit2: ok, the solution was in sys.path - I have installed the latest RC of pandas, which is on a non-standard path, and that's why it didn't work when I simply added the std site-packages path alone:</p> <pre><code>sys.path.append('/Users/admin/dev/pandas/pandas-0.11.0rc1') sys.path.append('/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages') </code></pre> <p>...works - thanks to all!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload