简体   繁体   English

无法在Windows上安装Python Scrapy(Lxml)

[英]Unable to install Python Scrapy (Lxml) on Windows

I was trying to install Python Scrapy library but when it's trying to install Lxml library, this error appears: 我正在尝试安装Python Scrapy库,但是在尝试安装Lxml库时,出现此错误:

Requirement already up-to-date: pip in c:\python34\lib\site-packages
Collecting lxml
  Using cached lxml-3.4.4.tar.gz
    Complete output from command python setup.py egg_info:
    Building lxml version 3.4.4.
    Building without Cython.
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "C:\Users\ALEJAN~1\AppData\Local\Temp\pip-build-b8ysz_w_\lxml\setup.py", line 230, in <module>
        **setup_extra_options()
      File "C:\Users\ALEJAN~1\AppData\Local\Temp\pip-build-b8ysz_w_\lxml\setup.py", line 144, in setup_extra_options
        STATIC_CFLAGS, STATIC_BINARIES)
      File "C:\Users\ALEJAN~1\AppData\Local\Temp\pip-build-b8ysz_w_\lxml\setupinfo.py", line 90, in ext_modules
        lib_versions = get_library_versions()
      File "C:\Users\ALEJAN~1\AppData\Local\Temp\pip-build-b8ysz_w_\lxml\setupinfo.py", line 308, in get_library_version
s
        xslt_version = run_command(find_xslt_config(), "--version")
      File "C:\Users\ALEJAN~1\AppData\Local\Temp\pip-build-b8ysz_w_\lxml\setupinfo.py", line 283, in run_command
        stdout=subprocess.PIPE, stderr=subprocess.PIPE)
      File "C:\Python34\lib\subprocess.py", line 858, in __init__
        restore_signals, start_new_session)
      File "C:\Python34\lib\subprocess.py", line 1111, in _execute_child
        startupinfo)
    FileNotFoundError: [WinError 2] El sistema no puede encontrar el archivo especificado

    ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in C:\Users\ALEJAN~1\AppData\Local\Temp\pip-build-b8ysz_
w_\lxml

I was checking the directory but everything seems to be ok. 我正在检查目录,但似乎一切正常。 Other libraries were installed without errors. 其他库的安装没有错误。

What can I do? 我能做什么?

I tried to install just Lxml, but Python shows it's not supported wheel on this platform. 我尝试仅安装Lxml,但Python显示此平台不支持它。

Sorry to inform you but Scrapy doesn't support Python3.4. 抱歉通知您,但Scrapy不支持Python3.4。

I had this exact issue and had been working myself up over why it wasn't working. 我遇到了这个确切的问题,并且一直在努力解决为什么它不起作用。 Fact is there hasn't been a port of Scrapy from 2.7 to 3.4 yet. 事实是,从2.7到3.4尚没有Scrapy港口。 You can use Scrapy if you have 2.7 如果您有2.7,则可以使用Scrapy

You have 2 options: Rewrite your code to run on Python 2.7 or use BeautifulSoup which is a web scraper in python compatible with Python 3.4 您有2种选择:重写代码以在Python 2.7上运行或使用BeautifulSoup(这是Python中与Python 3.4兼容的Web抓取工具)

I was trying to fix the error all day long and I can't find the exact solution. 我整天都在尝试修复错误,但找不到确切的解决方案。 I ended up uninstalling and installing Python (2.7.9) again and adding to the Path C:\\Python27\\Scripts (besides C:\\Python27\\ , that has been there all the time). 最后,我再次卸载并安装了Python(2.7.9),然后将其添加到路径C:\\Python27\\Scripts (除了C:\\Python27\\之外,该路径一直存在)。 Now it works! 现在可以了! Still don't have idea if this is what was causing the error. 仍然不知道这是否是导致错误的原因。

  1. Install Anaconda Python distribution. 安装Anaconda Python发行版。 It comes with lxlm preinstalled. 它预装了lxlm。
  2. Open cmd and type: 打开cmd并输入:

conda install scrapy 康达安装刮

Conda is Anaconda's package manager like pip. Conda是Anaconda的打包经理,就像pip一样。

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

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