通过pip安装pysftp失败了(因为2个python2.x版本?)

时间:2015-12-14 15:04:49

标签: python pip version pysftp

我的Ubuntu 10.04附带Python 2.6。现在,我还安装了Python 2.7,这是系统默认的,因为当我从终端启动$_SESSION["example"]时,它启动python 2.7。

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

pip install pysftp

在我看来,pip(显然在安装Python 2.7之前安装)链接到旧版本的Python,它不支持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 --version

当我pip 0.3.1 from /usr/lib/python2.6/dist-packages (python 2.6) 时,它会向我提供以下信息:

whereis python

如何安装pysftp?

2 个答案:

答案 0 :(得分:0)

您需要为Python 2.7重新安装pip,然后运行pip2.7 install pysftp。您需要为要使用它的每个Python版本安装pipsetuptools包可能是最简单的方法;你可以简单地运行以下命令一下子完成所有这一切:

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

有时,较旧的Linux安装程序会出现上述命令的问题,因为&#34;无效&#34;通过setuptoolssee here下载完整的ez_setup.py包时可以获得证书,以获取更多详细信息。这可以通过这种替代的一键式命令来规避:

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

答案 1 :(得分:-1)

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

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

然后您可以安装:

sudo pip install pysftp
sudo pip install enum