Re: [mongodb-user] How to install pymongo for python3 under Ubuntu 12.*?

1,006 views
Skip to first unread message

Bernie Hackett

unread,
Feb 15, 2013, 8:58:45 AM2/15/13
to mongod...@googlegroups.com
Hi,

On most Linux machines "python" is some python 2.x release (likely
python 2.7 on your machine), not python 3. "pip" is going to try to
install pymongo for python 2.x, not python 3. See
http://www.python.org/dev/peps/pep-0394/ for why this is so. Here are
some ways to install pymongo for python 3. These examples assume you
are using python 3.2:

python3.2 setup.py install (installing "from source")
pip-3.2 install pymongo
easy_install-3.2 pymongo

The second example assumes you have pip installed for python 3.2. The
third example assumes you have "distribute" (a fork of setuptools that
supports python 3) installed for python 3.2.


On Fri, Feb 15, 2013 at 3:24 AM, Jim Holmström <jim.hol...@gmail.com> wrote:
> I have tried to install pymongo for python3 in all ways imaginable
>
> I recently posted to stackoverflow but without any luck:
> http://stackoverflow.com/questions/14879527/installation-of-pymongo-works-but-fails-at-import-in-python3
>
> "
>
> I'm currently running Ubuntu 12.10 and tried to get pymongo to work properly
> under python3. Things I have tried:
>
> 1. apt-get install python-pymongo
> 2. python setup.py install #from git source
> 3. easy_install pymongo
> 4. easy_install pymongo3
> 5. pip install pymongo
> 6. pip install pymongo3 #needed a fix in the download script
>
> I have also removed and cleaned between the installations as best as I
> could.
>
> If I import pymongo:
>
> In [1]: import pymongo
> ---------------------------------------------------------------------------
> NameError Traceback (most recent call last)
> <ipython-input-1-ec8fdd1cd630> in <module>()
> ----> 1 import pymongo
>
> /usr/local/lib/python3.2/dist-packages/pymongo-2.4.2_-py3.2-linux-x86_64.egg/pymongo/__init__.py
> in <module>()
> 55 return '.'.join(map(str, version_tuple))
> 56
> ---> 57 version = get_version_string()
> 58 """Current version of PyMongo."""
> 59
>
> /usr/local/lib/python3.2/dist-packages/pymongo-2.4.2_-py3.2-linux-x86_64.egg/pymongo/__init__.py
> in get_version_string()
> 51
> 52 def get_version_string():
> ---> 53 if isinstance(version_tuple[-1], basestring):
> 54 return '.'.join(map(str, version_tuple[:-1])) +
> version_tuple[-1]
> 55 return '.'.join(map(str, version_tuple))
>
> NameError: global name 'basestring' is not defined
>
> The error is the same as pymongo FAQ but for me it doesn't matter where I'm
> located.
>
> My theory is that the python2 version of pymongo has mistakenly been added
> python3.
>
> "
>
> also tried to install it for my laptop (Ubuntu 12.04), but on my laptop
> python3 cannot find the package `pymongo` but python2 does :S
>
> How are one supposed to do when installing for python3 under Ubuntu? The
> README simple says 'python setup.py install' but it doesn't work.
> Additionally I'm thinking of downgrading to 12.04 since 12.10 in my opinion
> isn't ready so installation instructions for either .04 or .10 is
> appreciated.
>
> Thanks
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com
> To unsubscribe from this group, send email to
> mongodb-user...@googlegroups.com
> See also the IRC channel -- freenode.net#mongodb
>
> ---
> You received this message because you are subscribed to the Google Groups
> "mongodb-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mongodb-user...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Jim Holmström

unread,
Feb 19, 2013, 4:35:40 AM2/19/13
to mongod...@googlegroups.com
pip-3.2 did the trick after installing both distributed and pip from source with python3
didn't manage to get the pymongo installation from source to work, but at least I'm satisfied

Thanks!
-Jim
Reply all
Reply to author
Forward
0 new messages