Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x Pymongo已经安装了pip,但可以';不能进口_Python 3.x_Import_Pymongo_Libraries - Fatal编程技术网

Python 3.x Pymongo已经安装了pip,但可以';不能进口

Python 3.x Pymongo已经安装了pip,但可以';不能进口,python-3.x,import,pymongo,libraries,Python 3.x,Import,Pymongo,Libraries,我正在尝试在我的计算机上运行Flask webapp,但在导入pymongo库时遇到一些问题。已下载,但无法导入: (sce_env) C:\Users\antoi\Documents\Programming\Learning\scentmate_rec\webapp>python -m pip3 install pymongo C:\Users\antoi\Documents\Programming\Learning\scentmate_rec\scraper\sce_env\Scrip

我正在尝试在我的计算机上运行Flask webapp,但在导入pymongo库时遇到一些问题。已下载,但无法导入:

(sce_env) C:\Users\antoi\Documents\Programming\Learning\scentmate_rec\webapp>python -m pip3 install pymongo
C:\Users\antoi\Documents\Programming\Learning\scentmate_rec\scraper\sce_env\Scripts\python.exe: No module named pip3

(sce_env) C:\Users\antoi\Documents\Programming\Learning\scentmate_rec\webapp>python -m pip install pymongo
Requirement already satisfied: pymongo in c:\users\antoi\documents\programming\learning\scentmate_rec\scraper\sce_env\lib\site-packages (3.11.1)

(sce_env) C:\Users\antoi\Documents\Programming\Learning\scentmate_rec\webapp>python app.py
Traceback (most recent call last):
  File "app.py", line 137, in <module>
    client = pymongo.MongoClient(
NameError: name 'pymongo' is not defined
(sce\u env)C:\Users\antoi\Documents\Programming\Learning\scentmate\u rec\webapp>python-m pip3 install pymongo
C:\Users\antoi\Documents\Programming\Learning\scentmate\u rec\scraper\sce\u env\Scripts\python.exe:没有名为pip3的模块
(sce_env)C:\Users\antoi\Documents\Programming\Learning\scentmate\u rec\webapp>python-m pip install pymongo
已满足要求:c:\users\antoi\documents\programming\learning\scentmate\u rec\scraper\sce\u env\lib\site包中的pymongo(3.11.1)
(sce_env)C:\Users\antoi\Documents\Programming\Learning\scentmate\u rec\webapp>python app.py
回溯(最近一次呼叫最后一次):
文件“app.py”,第137行,在
client=pymongo.MongoClient(
NameError:未定义名称“pymongo”
奇怪的是,它在我的另一个项目中完美地工作


那么,如何让应用程序找到pymongo库呢?

当模块未首先导入时,会出现
名称错误
。您需要先导入模块。添加

import pymongo
在文件顶部(或其他适当位置)

如果未安装模块,而您尝试导入该模块,则会出现
ModuleNotFoundError
,例如

ModuleNotFoundError: No module named 'pymongo'