简体   繁体   English

不能用Python 3安装scrapy?

[英]Can't install scrapy with Python 3?

I am using Python 3.6.3 and Pip 9.0.1 but still can't install scrapy?我正在使用 Python 3.6.3 和 Pip 9.0.1 但仍然无法安装 scrapy? I am doing this on windows. When executing the following command我在 windows 上执行此操作。执行以下命令时

pip3 install scrapy

I am greeted with this error first..我首先遇到这个错误..

----------------------------------------
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

Then it continues, the second error stops it completly and seems a lot more fatal...然后它继续,第二个错误完全停止它并且似乎更致命......

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\

I have tried executing the following commands as suggested on this answer :我已尝试按照此答案中的建议执行以下命令:

pip install -U setuptools
pip install -U wheel

I had the same problem too but I solved it as follow:我也有同样的问题,但我解决了如下:

Open the Anaconda Prompt as administrator (For Windows10 : open cortana /search Anaconda Prompt /choose Run as Administrator )以管理员身份打开 Anaconda Prompt(对于Windows10 :打开cortana /search Anaconda Prompt /choose Run as Administrator

You should go to the path of Anaconda, for me was like:你应该走 Anaconda 的道路,对我来说就像:

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

Then you should run the following command然后你应该运行以下命令

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

At some point it asks在某些时候它会问

Proceed ([y]/n)?

type y .输入y Now twisted is installed.现在安装了twisted

To install scrapy , you either install it in Anaconda Prompt (as administrator) by running the following command:要安装scrapy ,您可以通过运行以下命令在Anaconda Prompt(以管理员身份)中安装它:

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

(again y for Proceed ([y]/n)?) (再次y表示Proceed ([y]/n)?)

or on jupyter notebook and run the command或者在jupyter notebook运行命令

!pip install scrapy

I am using Python 3.6.3 and Pip 9.0.1 but still can't install scrapy?我正在使用Python 3.6.3和Pip 9.0.1,但仍然无法安装scrapy? I am doing this on windows.我正在Windows上执行此操作。 When executing the following command执行以下命令时

pip3 install scrapy

I am greeted with this error first..我首先遇到这个错误。

----------------------------------------
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

Then it continues, the second error stops it completly and seems a lot more fatal...然后它继续,第二个错误完全停止了它,似乎更致命了...

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\

I have tried executing the following commands as suggested on this answer :我曾尝试执行以下命令对所建议的这个答案

pip install -U setuptools
pip install -U wheel

for my env: Win11 x64 + Python 3.11 x64对于我的环境: Win11 x64 + Python 3.11 x64

Solution:解决方案:

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

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