Skip to content

Issues with mod_wsgi? #284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
evandavey opened this issue Oct 24, 2011 · 7 comments
Closed

Issues with mod_wsgi? #284

evandavey opened this issue Oct 24, 2011 · 7 comments

Comments

@evandavey
Copy link

Hi,
I keep getting a 'module' object has no attribute 'core' when using with mod_wsgi. Please see http://stackoverflow.com/questions/7766400/pandas-django-mod-wsgi-virtualenv for the full error description.
Evan

@wesm
Copy link
Member

wesm commented Oct 24, 2011

What error do you get trying to do:

import pandas._tseries
import pandas._sparse

This sort of error happens when there was an import error suppressed somewhere so that pandas/init.py didn't fully execute.

I am not well-equipped to debug this myself. Not sure what to tell you.

@evandavey
Copy link
Author

Ok, that produced a slightly different error. Looks like this line 'module compiled against API version 6 but this version of numpy is 4' is the problem but not sure what it means... Both numpy and pandas installed using pip inside the virtual environment as in "pip install numpy; pip install pandas"

[Mon Oct 24 15:05:35 2011] [info] Initial (No.1) HTTPS request received for child 0 (server openportfolio-staging.XX.com:443)
[Mon Oct 24 15:05:35 2011] [info] mod_wsgi (pid=12433): Create interpreter 'openportfolio-staging'.
[Mon Oct 24 15:05:35 2011] [info] [client XX.XX.XX.XX] mod_wsgi (pid=12433, process='openportfolio-staging', application='openportfolio-staging'): Loading WSGI script '/usr/local/web/django/www/staging/openportfolio/apache/staging.wsgi'.
[Mon Oct 24 15:05:35 2011] [error] RuntimeError: module compiled against API version 6 but this version of numpy is 4
[Mon Oct 24 15:05:35 2011] [error] [client XX.XX.XX.XX] mod_wsgi (pid=12433): Target WSGI script '/usr/local/web/django/www/staging/openportfolio/apache/staging.wsgi' cannot be loaded as Python module.
[Mon Oct 24 15:05:35 2011] [error] [client XX.XX.XX.XX] mod_wsgi (pid=12433): Exception occurred processing WSGI script '/usr/local/web/django/www/staging/openportfolio/apache/staging.wsgi'.
[Mon Oct 24 15:05:35 2011] [error] [client XX.XX.XX.XX] Traceback (most recent call last):
[Mon Oct 24 15:05:35 2011] [error] [client XX.XX.XX.XX] File "/usr/local/web/django/www/staging/openportfolio/apache/staging.wsgi", line 22, in
[Mon Oct 24 15:05:35 2011] [error] [client XX.XX.XX.XX] import pandas._tseries
[Mon Oct 24 15:05:35 2011] [error] [client XX.XX.XX.XX] File "/usr/local/web/django/www/staging/env/openportfolio/lib/python2.7/site-packages/pandas/init.py", line 12, in
[Mon Oct 24 15:05:35 2011] [error] [client XX.XX.XX.XX] from pandas.core.api import *
[Mon Oct 24 15:05:35 2011] [error] [client XX.XX.XX.XX] File "/usr/local/web/django/www/staging/env/openportfolio/lib/python2.7/site-packages/pandas/core/api.py", line 8, in
[Mon Oct 24 15:05:35 2011] [error] [client XX.XX.XX.XX] from pandas.core.common import isnull, notnull, set_printoptions
[Mon Oct 24 15:05:35 2011] [error] [client XX.XX.XX.XX] File "/usr/local/web/django/www/staging/env/openportfolio/lib/python2.7/site-packages/pandas/core/common.py", line 13, in
[Mon Oct 24 15:05:35 2011] [error] [client XX.XX.XX.XX] import pandas._tseries as lib
[Mon Oct 24 15:05:35 2011] [error] [client XX.XX.XX.XX] ImportError: numpy.core.multiarray failed to import

@wesm
Copy link
Member

wesm commented Oct 24, 2011

hm, do you have multiple numpy's or multiple python interpreters installed on this box? try rebuilding pandas against the right one

@wesm
Copy link
Member

wesm commented Oct 24, 2011

Also, FYI you should take some care about installing NumPy from source. You almost certainly won't get optimized linear algebra out of the box-- so if you're using np.dot anywhere or anything in numpy.linalg (or any libraries that do) you should take a closer look there.

@evandavey
Copy link
Author

So it turns out this was a Python path order issue. By running sys.path.reverse() in my wsgi config file, the code now runs.

I double checked that numpy and pandas had been built against the right version - which they had (makes sense since it all worked outside mod_wsgi). However, due to the order of Python path, the built in OS X numpy library must have been imported first causing the issue.

Thanks for your help.

@evandavey
Copy link
Author

(and thanks for the info re: efficiency - I only build from source because I am trying to create an easy to install django app and a pip requirements file seems the easiest way to achieve this).

@wesm
Copy link
Member

wesm commented Oct 24, 2011

Cool, glad you got it working =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants