我的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安装之前安装的)链接到旧版本的Python,它不支持pysftp。还因为当我执行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?
2条答案
按热度按时间frebpwbc1#
你需要为Python 2.7重新安装
pip
,然后运行pip2.7 install pysftp
。你需要为你想要使用的每个Python版本安装pip
。setuptools
包可能是最简单的方法;你可以简单地运行以下命令来一次性完成所有操作:字符串
有时旧版Linux安装会出现上述命令的问题,因为在通过
ez_setup.py
下载完整的setuptools
包时会出现“无效”证书的问题(有关更多详细信息,请参阅此处)。可以使用以下替代命令来规避此问题:型
2exbekwf2#
我认为你需要安装某种'必需品包'使用的代码
字符串
然后你可以安装:
型