当前位置:网站首页>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 .
边栏推荐
- 记录一下刷LeetCode瞬间有思路的一道简单题——剑指 Offer 09. 用两个栈实现队列
- 网络连接验证
- Oracle writes a trigger that inserts a piece of data first and updates a field in the data
- Raspberry pie sends hotspot for remote login
- Unable to start debugging. Unexpected GDB output from command “-environment -cd xxx“ No such file or
- 别再吃各种维生素C片了,这6种维生素C含量最高的水果
- 猕猴桃酵素的功效_过路老熊_新浪博客
- Number array de duplication in JS
- huibian
- 关于运行scrapy项目时提示 ModuleNotFoundError: No module named 'pymongo‘的解决方案
猜你喜欢

Thrift入门学习

手工制作 pl-2303hx 的USB转TTL电平串口的电路_过路老熊_新浪博客

数组常用的一些操作方法

MySQL version upgrade + data migration

Common problems encountered when creating and publishing packages using NPM

兆欧表电压档位选择_过路老熊_新浪博客

About Simple Data Visualization

WINCC与STEP7的仿真连接_过路老熊_新浪博客

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

keil编译运行错误,缺少error:#5:#includecore_cm3.h_过路老熊_新浪博客
随机推荐
Static keyword explanation
Doris 运维中遇到的问题
MySQL version upgrade + data migration
Read CSV file data in tensorflow
Search rotation array ii[Abstract dichotomy exercise]
Implement const in Es5
Mutual conversion of float type data and datetime type data in sqlserver2008
记录一下刷LeetCode瞬间有思路的一道简单题——剑指 Offer 09. 用两个栈实现队列
用ES5的方式实现const
How to configure SQL Server 2008 Manager_ Old bear passing by_ Sina blog
网络连接验证
Common methods of object class
One article explains R & D efficiency! Your concerns are
C ++ 引用与指针总结
Using swiper to realize the rotation chart
【微信公众号H5】 生成带参数进入公众号关注页的二维码 监听用户关注公众号事件 自定义菜单栏 (服务端)
Literature research (I): hourly energy consumption prediction of office buildings based on integrated learning and energy consumption pattern classification
JS中常用知识点
InputStream流已经关闭了,但是依旧无法delete文件或者文件夹,提示被JVM占用等
Stream in PHP socket communication_ Understanding of select method