Difficulties with installation of python3 packages pymongo

29 views
Skip to first unread message

Bastien Sevajol

unread,
Aug 2, 2017, 12:58:45 AM8/2/17
to mongodb-user
Hello,

I have difficulties with installation of python3 version of pymongo package in version 2.9.5 (available here: https://pypi.python.org/pypi/pymongo/2.9.5). I cannot use last pymongo package version because my project use Ming (https://pypi.python.org/pypi/Ming) who only support pymongo<3.0.

When pymongo is installed on debian stretch or jessie, no problem. Installed files are python3 files. Example with docker:

1. Start a container with: docker run -it debian:stretch /bin/bash
2. Install pymongo for python 3 with: apt-get update && apt-get install -y python3-pip && pip3 install pymongo==2.9.5
3. Check file a pymongo file: cat /usr/local/lib/python3.5/dist-packages/pymongo/__init__.py | grep basestring        
--> output is empty

But in "hand make" docker image:

1. Start teh container (i will detail how container is built)
2. Install pymongo for python 3 with: apt-get update && apt-get install -y python3-pip && pip3 install pymongo==2.9.5
3. Check file a pymongo file (this test is positive in second case): cat /usr/lib/python3.5/site-packages/pymongo/__init__.py | grep basestring
---> output is: "if isinstance(version_tuple[-1], basestring):"

Code in /usr/lib/python3.5/site-packages/pymongo/ is python2 code. So it fail when executed with python3. The docker image is an image build with Yocto and https://layers.openembedded.org/layerindex/recipe/61661/ recipe. For example, some packages versions:

- python3 == 3.5.2 
- python3-pip == 9.0.1 
- git == 2.11.1
- gcc ==  6.3.0
- binutils == 2.28

Do you have an idea why pymongo package is installed with python2 files in second case ? Thank you,
Bastien.

Note: i don't know with but in debian stretch example, pymongo files are in /usr/local/lib/python3.5/dist-packages dir and in my "hand make" docker image pymongo files are in /usr/lib/python3.5/site-packages.

Bernie Hackett

unread,
Aug 2, 2017, 1:44:11 PM8/2/17
to mongodb-user
PyMongo 2.x uses 2to3 to convert itself to python 3 compatible syntax at install time. My guess is that in your "hand make" docker image 2to3 didn't run. I don't know why that would be. Can you try again using the -v option to pip, so we can see exactly how pip installs pymongo (pip3 install -v pymongo==2.9.5)?

Bastien Sevajol

unread,
Aug 3, 2017, 3:57:51 AM8/3/17
to mongodb-user
Hello, Thank you for your attention. I join the install log in attached file.

Bastien.
pip_pymongo.log

Bastien Sevajol

unread,
Aug 3, 2017, 5:26:19 AM8/3/17
to mongodb-user
Hello again,

After more investigation, i found where is the problem: The concerned used image built without 2to3 binary. That explain why code conversion is not applied. Problem here is the silent error ... I'm contacting python/setup tools maintainers about that.

Thank's you for your time!

Bastien.
Reply all
Reply to author
Forward
0 new messages