6

I am currently trying to install MongoDB driver for Python on my Mac OS X (mavericks).

But when I run

[ Dsl  ~/Documents/python ] sudo easy_install pymongo

I get the following output

Searching for pymongo
Best match: pymongo 2.7
Processing pymongo-2.7-py2.7-macosx-10.9-intel.egg
Removing pymongo 2.7rc1 from easy-install.pth file
Adding pymongo 2.7 to easy-install.pth file

Using /Library/Python/2.7/site-packages/pymongo-2.7-py2.7-macosx-10.9-intel.egg
Processing dependencies for pymongo
Finished processing dependencies for pymongo

I try a lot of different commands, but nothing work. How to install pymongo ?

Thanks for your help

Edit: When I try to use it in a python script

#!/usr/bin/env python3
import pymongo

client = MongoClient()

I have this error

Traceback (most recent call last):
  File "./mongo.py", line 2, in <module>
    import pymongo
ImportError: No module named 'pymongo'
Markus W Mahlberg
  • 19,711
  • 6
  • 65
  • 89
Anthony
  • 177
  • 1
  • 4
  • 14
  • there does not seem to be any error in the install, does it not work? – njzk2 Oct 06 '14 at 14:59
  • I think fireup a terminal and see if you can import PyMongo package – Sidharth Shah Oct 06 '14 at 15:00
  • When I try to use it I have ImportError: No module named 'pymongo' – Anthony Oct 06 '14 at 15:00
  • The script is using python3, but pymongo is installed only in Python2.7 - you need to install it for the correct version of Python you are using. – Burhan Khalid Oct 06 '14 at 15:10
  • 1
    It's work with Python2.7 but I need to use it with python 3. (I have Python 3.4.1 with the problem No module named 'pymongo') – Anthony Oct 07 '14 at 08:24
  • Possible duplicate of [installation of pymongo works but fails at import in python3](http://stackoverflow.com/questions/14879527/installation-of-pymongo-works-but-fails-at-import-in-python3) – uma Oct 08 '15 at 01:28
  • try this : http://api.mongodb.com/python/current/installation.html#installing-from-source Installing from source – Road Name Dec 01 '18 at 17:15

10 Answers10

6

Try these commands. Source

$ easy_install -U setuptools
$ python -m easy_install pymongo
Jayram
  • 18,820
  • 6
  • 51
  • 68
  • 3
    It's work with Python2.7 but I need to use it with python 3. (I have Python 3.4.1 with the problem No module named 'pymongo') – Anthony Oct 07 '14 at 08:24
  • @AnthonyPradal ImportError: No module named flask_pymongo same error for me as well. How to tackle? – Vaibhav Kadam Jun 10 '18 at 13:47
6

I have same error , and I can fix it following command.

sudo pip3 install pymongo

sudo apt-get install python3-pip

Try this. but this command for Ubuntu 14.04 OX.not sure is this work in Max OS X.

uma
  • 1,477
  • 3
  • 32
  • 63
4
python3 -m pip install pymongo

worked for me in OS X

2

Installing pymongo goes very simple

Make sure that python is installed already in your machine.If not check here for quick installation.

CentOS:

Update using yum

yum -y update

Download the pip using curl:

curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"

Install pip command using python

python get-pip.py

Install pymongo using pip

pip install pymongo
Jerry
  • 7,863
  • 2
  • 26
  • 35
1

On Ubuntu 18.04,

For this, the version of the pip should be less than or the same as 9.0.1.

First of all, install the pip for python version 3 from-

sudo apt install python3-pip

and check pip version-

pip --version

after that, we have to install build-essential for python-dev

sudo apt-get install build-essential python-dev

and python setup-tools

sudo apt-get install python-setuptools

And finally, we are able to install pymongo by following command-

python -m pip install pymongo

It worked for me, may it will work for you too.

Arun Kumar
  • 91
  • 1
  • 7
0

you can use these commands

python -m pip install pymongo

To get a specific version of pymongo:

$ python -m pip install pymongo==3.1.1

To upgrade using pip:

$ python -m pip install --upgrade pymongo

To use easy_install from setuptools do:

$ python -m easy_install pymongo

To upgrade do:

$ python -m easy_install -U pymongo
Ash Upadhyay
  • 1,796
  • 2
  • 15
  • 20
0

I think you can download the .egg file here and install with

sudo easy_install //filename
Rob
  • 26,989
  • 16
  • 82
  • 98
0

The following worked for me on Windows 10:

pip install -- upgrade pymongo
Don Brody
  • 1,689
  • 2
  • 18
  • 30
Syed
  • 1
-1
For ubuntu , you can try...
sudo pip3 install pymongo

sudo apt-get install python3-pip

It works for me

Yogesh Nikam Patil
  • 1,192
  • 13
  • 18
-1

I'm running python 2.7.12 on Rasbian Jesse. After running:

pip install pymongo

The following command reveals that the pymongo module exists under /usr/local/lib/python2.7/dist-packages/

pip show pymongo

One methods that works is to append the sys path with the location of the pymongo module:

import sys
sys.path.append('/usr/local/lib/python2.7/dist-packages/')
import pymongo
D1v3
  • 101
  • 1
  • 11