簡體   English   中英

scrapy需要Python 2.7,但已經是

[英]scrapy requires Python 2.7 but already it is

我安裝了Python 2.7,然后嘗試通過pip安裝scrapy 它不起作用,所以我刪除scrapy並試圖通過pip再次安裝。 當我這樣做時,我得到以下錯誤:

src/lxml/lxml.etree.c:192359: error: âxsltDocDefaultLoaderâ undeclared (first use in this function)

src/lxml/lxml.etree.c:192368: error: âxsltDocLoaderFuncâ undeclared (first use in this function)

src/lxml/lxml.etree.c:192368: error: expected â)â before â__pyx_f_4lxml_5etree__xslt_doc_loaderâ

error: command 'gcc' failed with exit status 1

----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools;__file__='/tmp/pip_build_root/lxml/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-fiN0SO-record/install-record.txt --single-version-externally-managed failed with error code 1 in /tmp/pip_build_root/lxml
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    load_entry_point('pip==1.4.1', 'console_scripts', 'pip')()
  File "/usr/lib/python2.6/site-packages/pip-1.4.1-py2.6.egg/pip/__init__.py", line 148, in main
    return command.main(args[1:], options)
  File "/usr/lib/python2.6/site-packages/pip-1.4.1-py2.6.egg/pip/basecommand.py", line 169, in main
    text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 81: ordinal not in range(128)

然后我嘗試運行scrapy ,但它抱怨它需要Python 2.7。 從下面的屏幕截圖中可以看出,我正在運行2.7版本。 有什么想法有什么不對?

在此輸入圖像描述

回溯顯示您正在使用python 2.6中的pip

你是如何安裝python 2.7的? 根據您的系統,您可能有一個pip2.7命令。 否則你可以嘗試為你的python 2.7安裝pip:

$ wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py
$ python get-pip.py

您可能需要在最后一個命令中使用sudo 一旦安裝了pip,強烈建議使用virtualenvpip install virtualenv )來安裝新的依賴項,而不是搞亂你的系統安裝。

或者,如果您安裝了最新的pip ,則可以使用選項--user在本地安裝軟件包,而無需sudo: pip install --user scrapy

此外,您似乎在安裝lxml遇到問題。 您使用的是什么版本的linux? 你安裝了庫libxml2-dev和libxslt-dev嗎?

驗證您是否具有scrapy和lxml的先決條件,並在任何缺少庫的情況下引用您的包管理器:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM