简体   繁体   中英

PyMongo error while running on Windows

I just installed pymongo from an.exe on a windows 7 box. I tried connecting to mongodb by:

import pymongo 
c = pymongo.Connection()

i get the following error:

Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
   c = pymongo.Connection()
File "E:\Softwares\installed\Python2.7\lib\site-packages\pymongo\connection.py", line 370, in __init__
self.__find_master()
File "E:\Softwares\installed\Python2.7\lib\site-packages\pymongo\connection.py", line 605, in __find_master
raise AutoReconnect("could not find master/primary")
AutoReconnect: could not find master/primary

I did some googling and i figured that the mongodb daemon is not running and hence i'm not able to connect. I tried doing the following:

c = pymongo.Connection('localhost', 27017)

But i got the same error. How do i start the mongodb deamon?? Or is there any other problem/error??

Thanks in advance:)

Go to http://www.mongodb.org/downloads to download the version of mongodb for your operating system.

Unzip the downloaded folder.

Run the file mongod.exe. (This is in the "bin" folder)

You should now be able to connect using pymongo.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM