简体   繁体   English

ModuleNotFoundError:没有名为“scrapy”的模块(PyCharm 中发生错误)

[英]ModuleNotFoundError: No module named 'scrapy' (Error happend in PyCharm)

I just create a new project in PyCharm, then try to run the command scrapy startproject filename.我只是在 PyCharm 中新建一个项目,然后尝试运行命令 scrapy startproject 文件名。 Then the error happened.然后错误发生了。

Traceback (most recent call last):

File "c:\users\管理员\appdata\local\programs\python\python38\lib\runpy.py", line 194, in
 _run_module_as_main
return _run_code(code, main_globals, None,

File "c:\users\管理员\appdata\local\programs\python\python38\lib\runpy.py", line 87, in
_run_code
exec(code, run_globals)

File "C:\Users\administrator\AppData\Local\Programs\Python\Python38\Scripts\scrapy.exe\__m
ain__.py", line 4, in <module>
ModuleNotFoundError: No module named 'scrapy'

Before I created this project, I had found that the administrator name was in Simple Chinese.在我创建这个项目之前,我发现管理员名称是简单的中文。 To avoid the further problem in other project, I modify the name from simply Chinese as well and the file name in C://users/管理员(where I installed the Python) and in the Path in system environment variables.为了避免在其他项目中出现进一步的问题,我也将名称从简体中文修改为C://users/管理员(我安装 Python 的地方)和系统环境变量中的路径中的文件名。

Does this error happen because of modification of the name?这个错误是因为修改了名字而发生的吗? Or is there any other default configuration in PyCharm I need to modify?或者PyCharm中还有其他默认配置需要修改吗?

After searching from a website named CSDN, I found this method works for my problem.从名为 CSDN 的网站搜索后,我发现此方法适用于我的问题。 I just briefly describe how I handle that.Hope it will be helpful for other people who meet the similar problem.我只是简单地描述一下我是如何处理的。希望它对遇到类似问题的其他人有所帮助。 The link: https://blog.csdn.net/weixin_39278265/article/details/82938270链接: https://blog.csdn.net/weixin_39278265/article/details/82938270

I installed the scrapy under C://user/管理员/.../Python38/... And yesterday after I installed scrapy, I found it doesn't work in Pycharm but, in MS-DOS, it worked. I installed the scrapy under C://user/管理员/.../Python38/... And yesterday after I installed scrapy, I found it doesn't work in Pycharm but, in MS-DOS, it worked. Some people told me the path with UTF-8 characters caused the problem.有人告诉我带有 UTF-8 字符的路径导致了问题。 So I modified the path from UTF-8 characters to English characters.于是我把UTF-8字符的路径修改为英文字符。

Then I deleted all the path environmental variables of Python in System and modified the path environmental variables of Python in Users from UTF-8 characters to English Characters.然后我将System中Python的路径环境变量全部删除,将Users中Python的路径环境变量从UTF-8字符修改为英文字符。

After that I opened the pip.exe, pip3.exe, scrapy.exe in...python38/scripts/ by Notepad and modified the path in the same way I did above.之后,我通过记事本在...python38/scripts/ 中打开了 pip.exe、pip3.exe、scrapy.exe,并以与上面相同的方式修改了路径。

After that I opened the PyCharm then run the command scrapy startproject projectname,it worked as in CMD interface and showed:之后我打开 PyCharm 然后运行命令 scrapy startproject projectname ,它在 CMD 界面中工作并显示:

You can start your first spider with: cd sxh01 scrapy genspider example example.com您可以使用以下命令开始您的第一个蜘蛛: cd sxh01 scrapy genspider 示例 example.com

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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