无法用Python 3安装scrapy?

时间:2017-12-18 22:15:40

标签: python scrapy

我使用的是Python 3.6.3和Pip 9.0.1,但仍然无法安装scrapy?我在Windows上这样做。执行以下命令时

pip3 install scrapy

我首先遇到这个错误..

----------------------------------------
Failed building wheel for Twisted
Running setup.py clean for Twisted
Failed to build Twisted
Installing collected packages: Twisted, scrapy
Running setup.py install for Twisted ... error

然后它继续,第二个错误完全停止它,似乎更致命......

Command "c:\users\admin\appdata\local\programs\python\python36-32\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\admin\\AppData\\Local\\Temp\\pip-build-zxkenzjd\\Twisted\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\admin\AppData\Local\Temp\pip-tr72roue-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\admin\AppData\Local\Temp\pip-build-zxkenzjd\Twisted\

我已按照this answer的建议尝试执行以下命令:

pip install -U setuptools
pip install -U wheel

2 个答案:

答案 0 :(得分:2)

我也遇到了同样的问题,但是我按照以下方法解决了它:

以管理员身份打开Anaconda提示符(对于Windows10:打开cortana /搜索Anaconda Prompt /选择Run as Administrator

您应该走到Anaconda的路,对我来说就像是

C:\WINDOWS\system32>cd ..
C:\WINDOWS>cd..
C:\>cd  ProgramData
C:\ProgramData>cd Anaconda3
C:\ProgramData>Anaconda3>

然后您应该运行以下命令

C:\ProgramData>Anaconda3>conda install -c anaconda twisted

在某个时候它会问

Proceed ([y]/n)?

键入y。现在twisted已安装。

要安装scrapy,请通过运行以下命令将其安装在Anaconda Prompt中(以管理员身份):

C:\ProgramData>Anaconda3>conda install -c conda-forge scrapy

(同样是y的{​​{1}}

或在Proceed ([y]/n)?)上并运行命令

jupyter notebook

答案 1 :(得分:0)

解决起来超级容易。您可以手动安装双绞线。我已经写了一篇文章。

  1. 转到此链接Twisted wheel(.whl)下载。
  2. 为您下载合适的车轮版本和二进制文件。 (在choosing the correct version and binary of Twisted时要小心)
  3. 冷静地,等待直到Twisted .whl下载完成。不会花很多时间。
  4. 现在在命令提示符下打开Twisted最新.whl所在的目录
  5. 在您的PC上运行此命令:pip install YourTwistedFileName_WithCorrectVersion&Binary.whl

这是解决方案:Instant Solution for Scrapy failed building wheel for Twisted

相关问题