无法使用pip在OSX上安装lxml:550无法更改目录

时间:2018-07-04 04:03:22

标签: pip lxml

我正在尝试使用pip3在OSX El Capitan上安装lxml;使用STATIC_DEPS进行了大量的谷歌搜索,但不幸的是,我现在收到一个错误,对我来说,这似乎意味着软件包中缺少文件:

$ STATIC_DEPS=true pip3 install lxml
Collecting lxml
  Using cached https://files.pythonhosted.org/packages/54/a6/43be8cf1cc23e3fa208cab04ba2f9c3b7af0233aab32af6b5089122b44cd/lxml-4.2.3.tar.gz
    Complete output from command python setup.py egg_info:
    Building lxml version 4.2.3.
    Latest version of zlib is 1.2.11
    Downloading zlib into libs/zlib-1.2.11.tar.gz from http://zlib.net/zlib-1.2.11.tar.gz
    Unpacking zlib-1.2.11.tar.gz into build/tmp
    Latest version of libiconv is 1.15
    Downloading libiconv into libs/libiconv-1.15.tar.gz from ftp://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz
    Unpacking libiconv-1.15.tar.gz into build/tmp
    Latest version of libxml2 is 2.9.8
    Downloading libxml2 into libs/libxml2-2.9.8.tar.gz from ftp://xmlsoft.org/libxml2/libxml2-2.9.8.tar.gz
    Unpacking libxml2-2.9.8.tar.gz into build/tmp
    Latest version of libxslt is 1.1.33
    Downloading libxslt into libs/libxslt-1.1.33.tar.gz from ftp://xmlsoft.org/libxml2/libxslt-1.1.33.tar.gz
    Traceback (most recent call last):
      File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 2417, in retrfile
        self.ftp.cwd(file)
      File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ftplib.py", line 631, in cwd
        return self.voidcmd(cmd)
      File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ftplib.py", line 278, in voidcmd
        return self.voidresp()
      File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ftplib.py", line 251, in voidresp
        resp = self.getresp()
      File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ftplib.py", line 246, in getresp
        raise error_perm(resp)
    ftplib.error_perm: 550 Failed to change directory.

    The above exception was the direct cause of the following exception:

    Traceback (most recent call last):
      File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 1540, in ftp_open
        fp, retrlen = fw.retrfile(file, type)
      File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 2419, in retrfile
        raise URLError('ftp error: %r' % reason) from reason
    urllib.error.URLError: <urlopen error ftp error: error_perm('550 Failed to change directory.')>

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/hp/_4p52dfd7s9cf49p86sg1l_w0000gp/T/pip-install-yjxema7x/lxml/setup.py", line 241, in <module>
        **setup_extra_options()
      File "/private/var/folders/hp/_4p52dfd7s9cf49p86sg1l_w0000gp/T/pip-install-yjxema7x/lxml/setup.py", line 150, in setup_extra_options
        STATIC_CFLAGS, STATIC_BINARIES)
      File "/private/var/folders/hp/_4p52dfd7s9cf49p86sg1l_w0000gp/T/pip-install-yjxema7x/lxml/setupinfo.py", line 75, in ext_modules
        multicore=OPTION_MULTICORE)
      File "/private/var/folders/hp/_4p52dfd7s9cf49p86sg1l_w0000gp/T/pip-install-yjxema7x/lxml/buildlibxml.py", line 390, in build_libxml2xslt
        libxslt_dir  = unpack_tarball(download_libxslt(download_dir, libxslt_version), build_dir)
      File "/private/var/folders/hp/_4p52dfd7s9cf49p86sg1l_w0000gp/T/pip-install-yjxema7x/lxml/buildlibxml.py", line 218, in download_libxslt
        version_re, filename, version=version)
      File "/private/var/folders/hp/_4p52dfd7s9cf49p86sg1l_w0000gp/T/pip-install-yjxema7x/lxml/buildlibxml.py", line 291, in download_library
        urlretrieve(full_url, dest_filename)
      File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 247, in urlretrieve
        with contextlib.closing(urlopen(url, data)) as fp:
      File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 222, in urlopen
        return opener.open(url, data, timeout)
      File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 525, in open
        response = self._open(req, data)
      File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 543, in _open
        '_open', req)
      File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 503, in _call_chain
        result = func(*args)
      File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 1551, in ftp_open
        raise exc.with_traceback(sys.exc_info()[2])
      File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 1540, in ftp_open
        fp, retrlen = fw.retrfile(file, type)
      File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 2419, in retrfile
        raise URLError('ftp error: %r' % reason) from reason
    urllib.error.URLError: <urlopen error ftp error: URLError("ftp error: error_perm('550 Failed to change directory.')")>

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/hp/_4p52dfd7s9cf49p86sg1l_w0000gp/T/pip-install-yjxema7x/lxml/

由于命令在Downloading libxslt into libs/libxslt-1.1.33.tar.gz from ftp://xmlsoft.org/libxml2/libxslt-1.1.33.tar.gz 上失败,因此我浏览了ftp://xmlsoft.org/libxml2/站点,该站点没有ftp://xmlsoft.org/libxml2/libxslt-1.1.33.tar.gz,只有ftp://xmlsoft.org/libxml2/libxslt-1.1.33-rc1.tar.gz

这是问题吗?如果是的话,有没有一种方法可以在包中覆盖它?还是我错过了什么?

1 个答案:

答案 0 :(得分:0)

您可以通过手动下载libxml2和libxslt并从setup.py进行构建,而在仍然具有STATIC_DEPS功能的同时绕过FTP错误。

从lxml网站粘贴:

  

...如果要使用   特定版本,或想要阻止任何在线访问,可以   自己下载两个tar.gz发行文件,并将它们放入一个   lxml发行版中的子目录libs,并使用   所需的目标版本如下:

     

python setup.py build --static-deps \          --libxml2-version = 2.9.1 \          --libxslt-version = 1.1.28 \

     

sudo python setup.py安装