bluemihai
bluemihai

Reputation: 454

uWSGI runs wrong version of Python

My django/uwsgi/python crashes with a segmentation fault because uWSGI is apparently loading a different version of Python.

I just installed uWSGI using pip. This SO question addresses a solution that involves compiling from source, but I'd like to avoid that.

mihai$ /usr/bin/python
Python 2.7.5 (default, Aug 25 2013, 00:04:04)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Segmentation fault: 11

mihai$ /usr/local/bin/python
Python 2.7.6 (v2.7.6:3a1db0d2747e, Nov 10 2013, 00:42:54)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>>

Any suggestions?

I was hoping for some --flag that can tell uWSGI what version of python to use...

Upvotes: 6

Views: 6266

Answers (2)

PolyTekPatrick
PolyTekPatrick

Reputation: 3142

One non-obvious thing which can cause this problem: you previously installed uwsgi using a different python environment and the resulting compiled uwsgi wheel got saved in your pip wheel cache. Then when you installed uwsgi in your current python environment, pip simply grabbed the cached wheel instead of actually rebuilding uwsgi for your current python version.

Watch the output closely to see if pip used a cached wheel. If so, you can either delete the cached wheel and reinstall uwsgi or reinstall using a command-line arg to disable the cache:

pip uninstall uwsgi
pip install --no-cache-dir uwsgi

Upvotes: 0

Sean Perry
Sean Perry

Reputation: 3886

Sadly if the python it is compiled against is the wrong one you have to recompile it. Since it is directly linked to the Python it was built for if you are using a different one the symbols won't match.

In the comments you mention you used pip but are not getting the right Python version. Perhaps you are using the wrong pip? For instance on Ubuntu you have Python 2.7 and 3.3. There is a pip-2.7 and a pip-3.3. If you are using virtualenv make sure you are installing with pip from the virtualenv.

Upvotes: 4

Related Questions