本文介绍了ImportError:没有名为"pymongo"的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用Python 3.4,mongodb 4.2.10的Win 7(64)上运行pymongo时遇到问题.错误输出如下:

I have a problem running pymongo on Win 7 (64) with Python 3.4, mongodb 4.2.10. The error output is as follows:

import pymongo
ImportError: No module named 'pymongo'

代码非常简单:

import pymongo
from pymongo import MongoClient

client=MongoClient()
db=client.test_db
dict={'A':[1,2,3,4,5,6]}
db.test_collection.insert(dict)
to_print=db.test_collection.find()
print(to_print)

我尝试已经重新安装Python和MongoDB-没有帮助.当我在cmd中手动进行操作时,它可以工作,即mongod.exe和mongo.exe可以正常工作. pymongo似乎有问题,但我不知道如何解决.

I tried already re-installing Python and MongoDB - did not help. It works when I do it manually in cmd, i.e. mongod.exe and mongo.exe work fine. It appears there is problem with pymongo, but I don't know how to fix it.

推荐答案

您所需要做的就是实际安装pymongo(当前您只有mongo和python,但他们不知道如何交谈).该页面正在告诉您 u确切的操作:

All you need is to actually install pymongo (currently you just have mongo and python, but they do not know how to speak with each other). This page is telling you exactly what to do:

这篇关于ImportError:没有名为"pymongo"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 09:03