【发布时间】:2020-04-23 02:31:33
【问题描述】:
我使用命令行安装了scrapy
pip install git+https://github.com/scrapy/scrapy@master --no-dependencies --upgrade
安装后,我尝试在我的一个 python 项目中导入 scrapy,但出现错误提示:
Traceback (most recent call last):
File "C:\Users\Lenovo\Desktop\Linkedin\script.py", line 7, in <module>
from scrapy import Selector
ImportError: No module named scrapy
[Finished in 0.983s]
我该怎么办?在 Google 上找不到正确的解决方案!
【问题讨论】:
-
1. pip install 是否确认已安装? 2. 你检查过 Python 是否在你的 PATH 中吗?
-
@FatihAkici,是的,我做到了。最初,scrapy 没有通过命令行安装。所以后来我在Visual code console上安装了它,后来我通过命令行检查,它确认它已经安装了。
-
如何运行引发错误的脚本?
-
我在 Atom 上运行它。最初在我的脚本上,对于这种语法
sel =Selector(text=driver.page_source)。我收到一个错误(` 'unicode' object has no attribute 'text'). So over searching on google, I came across Scrapy, where that uniode error could be solved by parsing the html (from scrapy.selector import Selector with open(person_path) as fp: sel = Selector(text=fp.read()) -
为什么要从 Github 源安装它?你在使用虚拟环境吗?
标签: python python-3.x pip scrapy package