在Debian 伸展,当我尝试通过安装 python 包 python-constraint 时
pip install python-constraint
我收到以下错误;
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 290, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1178, in prepare_files
url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
File "/usr/lib/python2.7/dist-packages/pip/index.py", line 292, in find_requirement
elif is_prerelease(version) and not (self.allow_all_prereleases or req.prereleases):
File "/usr/lib/python2.7/dist-packages/pip/util.py", line 739, in is_prerelease
return any([any([y in set(["a", "b", "c", "rc", "dev"]) for y in x]) for x in parsed])
TypeError: 'int' object is not iterable
Storing debug log for failure in /home/von/.pip/pip.log
在Debian 杰西同样的命令是成功的。
哪里有问题?怎么解决呢?
$python --version
Python 2.7.9
$pip --version
pip 1.5.6 from /usr/lib/python2.7/dist-packages (python 2.7)
答案1
该错误与错误有关https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=786580
解决办法是降级python-distlib
到python-distlib-whl
jessie版本。
wget http://ftp.debian.org/debian/pool/main/d/distlib/python-distlib_0.1.9-1_all.deb
wget http://ftp.debian.org/debian/pool/main/d/distlib/python-distlib-whl_0.1.9-1_all.deb
dpkg -i python-distlib_0.1.9-1_all.deb
dpkg -i python-distlib-whl_0.1.9-1_all.deb
之后运行pip install
就成功了。
$ sudo pip install python-constraint
Downloading/unpacking python-constraint
Downloading python-constraint-1.2.tar.bz2
Running setup.py (path:/tmp/pip-build-JeOIzg/python-constraint/setup.py) egg_info for package python-constraint
Installing collected packages: python-constraint
Running setup.py install for python-constraint
Successfully installed python-constraint
Cleaning up...
暂时搁置这些软件包,等待官方修复错误。
sudo aptitude hold python-distlib python-distlib-whl
答案2
我在 Raspbian 上尝试安装不同的软件包时遇到了这个问题,并且由于同样的错误,pip 无法自行更新。使用 apt-get 升级 pip 解决了这个问题:
sudo apt-get install python3-pip