0

我的 Ubuntu 10.04 带有 Python 2.6。现在,我还安装了 Python 2.7,这是系统默认的,因为当我python从终端启动时,它会启动 python 2.7。

现在,我想使用 pip 安装库 pysftp,但我很难这样做。以下是我的尝试和结论的一些结果。我做了pip install pysftp,但它说以下内容:

Downloading/unpacking pysftp
  Running setup.py egg_info for package pysftp
    Traceback (most recent call last):
      File "<string>", line 3, in <module>
      File "/usr/local/lib/python2.6/dist-packages/setuptools/__init__.py", line 12, in <module>
        from setuptools.extension import Extension
      File "/usr/local/lib/python2.6/dist-packages/setuptools/extension.py", line 8, in <module>
        from .dist import _get_unpatched
      File "/usr/local/lib/python2.6/dist-packages/setuptools/dist.py", line 21, in <module>
        packaging = pkg_resources.packaging
    AttributeError: 'module' object has no attribute 'packaging'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 3, in <module>

  File "/usr/local/lib/python2.6/dist-packages/setuptools/__init__.py", line 12, in <module>

    from setuptools.extension import Extension

  File "/usr/local/lib/python2.6/dist-packages/setuptools/extension.py", line 8, in <module>

    from .dist import _get_unpatched

  File "/usr/local/lib/python2.6/dist-packages/setuptools/dist.py", line 21, in <module>

    packaging = pkg_resources.packaging

AttributeError: 'module' object has no attribute 'packaging'

----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in ./pip-log.txt

在我看来,pip(显然是在安装 Python 2.7 之前安装的)链接到不支持 pysftp 的旧版 Python。也因为当我这样做pip --version时说:

pip 0.3.1 from /usr/lib/python2.6/dist-packages (python 2.6)

当我这样做时whereis python,它会给我以下信息:

python: /usr/src/Python-2.7.10/python /usr/bin/python2.6 /usr/bin/python /etc/python2.6 /etc/python /usr/lib/python2.6 /usr/lib/python3.1 /usr/lib64/python2.6 /usr/lib64/python3.1 /usr/local/bin/python2.7-config /usr/local/bin/python /usr/local/bin/python2.7 /usr/local/lib/python2.6 /usr/local/lib/python2.7 /usr/include/python2.6 /usr/share/python /usr/share/man/man1/python.1.gz

如何安装 pysftp?

4

2 回答 2

0

您需要重新安装pipPython 2.7,然后运行pip2.7 install pysftp​​. 您需要pip为要使用的每个 Python 版本进行安装。setuptools打包可能是最简单的方法。您可以简单地运行以下命令一举完成所有操作:

wget https://bootstrap.pypa.io/ez_setup.py -O --no-check-certificate - | sudo python2.7 && sudo easy_install-2.7 pip && sudo pip2.7 install pysftp

setuptools有时较旧的 Linux 安装会出现上述命令的问题,因为在通过下载完整包时遇到“无效”证书ez_setup.py(有关更多详细信息,请参见此处)。这可以通过这个替代的 one-fell-swoop 命令来规避:

wget https://pypi.python.org/packages/source/s/setuptools/setuptools-18.8.1.zip --no-check-certificate && unzip setuptools-18.8.1.zip && cd setuptools-18.8.1 && sudo python setup.py install && sudo easy_install-2.7 pip && sudo pip2.7 install pysftp
于 2015-12-14T15:11:43.000 回答
-1

我认为您需要使用代码安装某种“基本包”

sudo apt-get install build-essential libssl-dev libffi-dev python-dev

然后你可以安装:

sudo pip install pysftp
sudo pip install enum
于 2018-08-09T10:39:33.823 回答