当前位置:网站首页>About the solution to prompt modulenotfounderror: no module named'pymongo 'when running the scratch project
About the solution to prompt modulenotfounderror: no module named'pymongo 'when running the scratch project
2022-06-26 00:04:00 【Falling ink painting snow】
1 Problem description
Use today scrapy The framework writes crawlers and uses mongodb When storing results , stay powershell Run in scrapy crawl demo Found an error , What is the content of the error report No module named 'pymongo‘, namely , Can't find pymongo modular , But I have actually downloaded this module , So what's going on ?
2 Problem analysis
First , It's important to point out that , It must be an environmental problem . Is it multiple python Version co-existence ? In my computer, there are Python2.7 and python3.6, At the beginning, it was installation anaconda when , The former is installed by default , The latter is required for work and study , meanwhile Python2 Will be eliminated , Installed Python3, As a result, there are two environments in my computer at the same time , and , The author will pymongo Installed in python36 in , Not installed in Python27 in , Lead to in powershell Run in scrapy By default python2.7, Therefore, the above error report is caused , So is it ?
3 Test the hypothesis
The best way to test a hypothesis is to try , Here the author first posts powershell Mistakes in :
Here, try the default Python27 You can also download this in the environment pymongo modular , Run it again , See if there is an error , give the result as follows :
It is found that it can run correctly , It seems that this is the problem , That is, it runs directly at the terminal scrapy The program will default to conda Of Python The default path , I am here Python2.7.
4 other
Use here cmd Try the terminal method , because powershell Count as cmd Upgraded version , The author has been tested ( To uninstall first Python2.7 Of pymongo Install again ) Separate tests found , It's really this conda Problems caused by the default environment of , But in the course of my test , And found a powershell problem , That is, it cannot be like cmd Switching environment : The following are in cmd and powershell Switch in Python Environment debugging
conda activate python Version number
I am here 36, Because it was installed conda When the default 27
conda activate Python36

Discover successful switching environments , But in powershell You can't 
therefore , Here we need to pay attention to , But since in cmd Environment can be switched in , Well, because I started with scrapy Is in python36 Written in , The reason for the mistake is powershell Only recognize the default Python27 edition , And I am Python27 There is no installation in pymongo, stay Python36 This module is installed in , So I am cmd Switch to Python36 Then run scrapy Just file it ?
True knowledge comes from practice :
It works
5 summary
Many people need to work and study , There will be multiple in the computer at the same time Python edition ,
(1) stay powershell function scrapy File program , Will be used by default conda Default environment , If there is no corresponding third-party module installed in the default environment , A similar error occurs when the module cannot be found , So you can install the same module in the default environment , At the same time, continue to use powershell start-up ;
(2) As the author found in the above analysis ,powershell Unable to switch environment , If you don't have to use powershell, It can be found at the terminal cmd in , Switch Python After interpreter , because pymongo Installed in the Python36 It's in , After switching, you can run directly .
All in all , If there is no multi version coexistence problem , There will be no problem with this article ; At the same time, if powershell It will also save a lot if you can switch versions debug Time .
边栏推荐
- 使用npm创建并发布包时遇到的常见问题
- MySQL InnoDB lock knowledge points
- STEP7主站与远程I/O组网_过路老熊_新浪博客
- 详解synchronize关键字
- Establishment of multiple background blocks in botu software_ Old bear passing by_ Sina blog
- Common knowledge points in JS
- Topic36——53. 最大子数组和
- Joint simulation of STEP7 and WinCC_ Old bear passing by_ Sina blog
- Unsigned and signed vernacular
- WINCC与STEP7的仿真连接_过路老熊_新浪博客
猜你喜欢

Alipay payment interface sandbox environment test and integration into an SSM e-commerce project

Efficacy of kiwi fruit enzyme_ Old bear passing by_ Sina blog

Unable to start debugging. Unexpected GDB output from command “-environment -cd xxx“ No such file or

《网络是怎么样连接的》读书笔记 - 集线器、路由器和路由器(三)

Let's talk about string today

推荐系统设计

ASA如何配置端口映射及PAT

The role of iomanip header file in actual combat

关于运行scrapy项目时提示 ModuleNotFoundError: No module named 'pymongo‘的解决方案

WINCC与STEP7的仿真连接_过路老熊_新浪博客
随机推荐
Redis之内存淘汰机制
6. common instructions (upper) v-cloak, v-once, v-pre
Lazy people teach you to use kiwi fruit to lose 16 kg in a month_ Old bear passing by_ Sina blog
Literature research (IV): Hourly building power consumption prediction based on case-based reasoning, Ann and PCA
Literature research (I): hourly energy consumption prediction of office buildings based on integrated learning and energy consumption pattern classification
huibian
Number array de duplication in JS
Object array de duplication
js实现输入开始时间和结束时间,输出其中包含多少个季,并且把对应年月打印出来
SSM integrated learning notes (mainly ideas)
IDEA常用快捷键
unsigned与signed之大白话
ValueError: color kwarg must have one color per data set. 9 data sets and 1 colors were provided解决
网络连接验证
在step7中实现模拟量数值与工程量数值之间的转换_过路老熊_新浪博客
在win10下使用visual studio2015链接mysql数据库
One article explains R & D efficiency! Your concerns are
我的博客今天2岁167天了,我领取了先锋博主徽章_过路老熊_新浪博客
Keil compilation run error, missing error: # 5: # includecore_ cm3.h_ Old bear passing by_ Sina blog
step7和wincc联合仿真_过路老熊_新浪博客