mongolab / mongoctl

Manage MongoDB servers and replica sets using JSON configurations!
MIT License
178 stars 25 forks source link

ImportError: No module named connection #19

Closed joegoggins closed 9 years ago

joegoggins commented 9 years ago

Apologies if this a total python newb issue rather than a mongoctl issue. I'm seeing the following behavior, any ideas on how to resolve?

After uninstalling and reinstalling python (2.7.9) via Homebrew on OS X 10.10 and trying pip installs with sudo and without, I keep getting this error:

Traceback (most recent call last):
  File "/usr/local/bin/mongoctl", line 48, in <module>
    from mongoctl import mongoctl
  File "/usr/local/lib/python2.7/site-packages/mongoctl/mongoctl.py", line 38, in <module>
    import objects.server
  File "/usr/local/lib/python2.7/site-packages/mongoctl/objects/server.py", line 21, in <module>
    from pymongo.connection import Connection
ImportError: No module named connection
asiebert commented 9 years ago

We are using the mongoctl cookbook to install it, and I just faced the same error when bootstrapping a new server. The issue can be easily reproduced in a fresh virtualenv though:

$ virtualenv venv

$ source venv/bin/activate

(venv)$ pip

(venv)$ pip install mongoctl
Downloading/unpacking mongoctl
  Downloading mongoctl-0.7.7.tar.gz (75kB): 75kB downloaded
  Running setup.py (path: …/venv/build/mongoctl/setup.py) egg_info for package mongoctl
…
Downloading/unpacking pymongo>=2.7 (from mongoctl)
  Downloading pymongo-3.0.1.tar.gz (381kB): 381kB downloaded
  Running setup.py (path:/ …/venv/build/pymongo/setup.py) egg_info for package pymongo
…
Successfully installed mongoctl dargparse pymongo verlib boto
Cleaning up...

(venv)$ pip list
argparse (1.2.1)
boto (2.31.1)
dargparse (0.2.5)
mongoctl (0.7.7)
pip (1.5.4)
pymongo (3.0.1)
setuptools (2.2)
verlib (0.1)
wsgiref (0.1.2)

(venv)$ mongoctl
Traceback (most recent call last):
  File "…/venv/bin/mongoctl", line 48, in <module>
    from mongoctl import mongoctl
  File "…/venv/local/lib/python2.7/site-packages/mongoctl/mongoctl.py", line 38, in <module>
    import objects.server
  File "…/venv/local/lib/python2.7/site-packages/mongoctl/objects/server.py", line 21, in <module>
    from pymongo.connection import Connection
ImportError: No module named connection

It would appear pymongo 3.0.1 is installed (which is the latest available) regardless of what is specified in the current setup.py. Downgrading pymongo to 2.8 is enough to fix the issue: pip install pymongo==2.8

Note: it seems the pymongo.connection.Connection indeed disappeared in pymongo 3.0, in favor of pymongo.MongoClient (e.g. https://github.com/shinken-monitoring/mod-mongodb/pull/7)

abdulito commented 9 years ago

Hi,

The issue has been fixed and a newer version has been pushed to pypi 0.7.81 which has the proper pymongo dependency. Sorry for the trouble but pypi was acting weird for some reason. It was downloading version 0.7.7 while 0.7.8 was available so i had to re-upload 0.7.8 under a different version 0.7.81 so it would become the default.

Cheers!

-abdul

joegoggins commented 9 years ago

Thanks @abdulito , works like a charm on OS X 10.10 now, much appreciated!