Pymongo installed, but import fails

CentOS 5.8 ships with Python 2.4.3. I installed pymongo using the command: sudo pip install pymongo (after installing pip with easy_install after installing python-pip ... typical CentOS, nothing comes out of the box).

Installation works, I get messages:

Successfully installed pymongo Cleaning up... 

Then, when I start pymongo import, I get the following:

ImportError: no module named pymongo

I followed the standard pymongo installation procedure, so pymongo definitely does not work on CentOS. Does anyone know of a workaround to get this to work? It seems like a hack is needed again for CentOS to support the basic functionality that every other Linux distribution supports out of the box.

+1
source share
1 answer

Since you did not specify that you need to use the standard CentOS Python installation, I highly recommend using virtualenv to get the necessary support. CentOS requires an older version of Python, and we must work with it in my business.

Take the latest Python and create it from the source code. Make sure the SSL devel libraries are installed through Yum.

 ./configure --prefix=/home/user/custompython make && make install 

Take virtualenv.py from https://raw.github.com/pypa/virtualenv/master/virtualenv.py and run this script from your custom python installation

 /home/user/custompython/bin/python virtualenv.py -P /home/user/custompython/bin/python /home/user/pythonENV export PYTHON_HOME=/home/user/pythonENV/ export PATH=/home/user/pythonENV/bin/:$PATH pip install pymongo 

Of course, adding path changes to .bashrc is useful. Now you can install whatever you want without worrying about the very old version 2.4.3 that comes with CentOS. This is the exact setup I have on our CentOS 5.8 system, and it is very useful.

+1
source

Source: https://habr.com/ru/post/1442187/


All Articles