我的Ubuntu 10.04附帶了Python 2.6。現在,我還安裝了Python 2.7,這是現在的系統默認值,因爲當我從終端啓動python
時,它會啓動python 2.7。通過pip安裝pysftp失敗(因爲有2個python2.x版本)
現在,我想使用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
在我看來,(安裝的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?
我得到了wget命令的證書錯誤(用'--no-check-certificate'解決)。然後腳本給出'返回狀態5'(同時爲setuptools調用wget)。手動下載該文件後,它會顯示「zipfile.BadZipfile:文件不是zip文件」。幫幫我? – Lewistrick
@Lewistrick這是不尋常的,我無法想象爲什麼它會試圖解壓縮一些東西......它在'sudo python2.7 ez_setup.py'部分失敗了? – Mego
是的,它試圖解壓本地版本的https:// pypi.python.org/packages/source/s/setuptools/setuptools-18.8.1.zip。它使用了錯誤的文件嗎? – Lewistrick