7
votes

I am currently runnning Ubuntu 12.04 with mongodb 2.2 and pymongo version 2.3. I am attempting to gather some information using Twitters API and I am getting an error when attempting to import mymongo. Here is what I have:

import pycurl, json
import pymongo


STREAM_URL = "https://stream.twitter.com/1/statuses/filter.json"
WORDS = "track=#obama"
USER = "myuser"
PASS = "mypass"

ImportError: No module named pymongo Any ideas?

4
Did you install it? If not try: sudo apt-get install python-pymongo - mjgpy3
Yes it is installed. I tried redoing the install and it is still giving me the same error. Could it be that I am missing a dependency for pymongo to work? - bardockyo
Do you have more than one version of python installed? Could it be installed for the other version? - Doug T.
I just checked to see which modules I have installed for python using pip freeze and it returned pymongo2.7- every module just has the name and version but for some reason pymongo has the dash after it.. could that mean anything? - bardockyo
Are you installing using sudo apt-get install python python-pymongo or are you using sudo pip install pymongo? I did a test on my local machine using pip install pymongo and had no issues. - Shawn H

4 Answers

8
votes

I had the same problem. Pymongo conflicts with the bson package. This worked for me:

sudo pip uninstall pymongo
sudo pip uninstall bson
sudo apt-get remove python-bson
sudo apt-get remove python-gridfs    # not sure if it's necessary
sudo pip install pymongo -U
4
votes

I was having the same issue and I installed it manually like this:

$ wget http://pypi.python.org/packages/source/p/pymongo/pymongo-2.3.tar.gz
$ tar xzf pymongo-2.3.tar.gz
$ cd pymongo-2.3
$ python setup.py install

Works for me. Good luck.

1
votes

cd /tmp/

wget --no-check-certificate https://github.com/mongodb/mongo-python-driver/archive/master.zip

unzip master.zip

cd mongo-python-driver-master/

python setup.py install

1
votes

I was having same issue. Easy way to do is install pip and install pymongo.

wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py python get-pip.py python -m pip install pymongo