以前一直在ubuntu14.04的python2.7上写selenium.最近想学习一下web接口测试,并且尝试一下python3,所以准备装个djongo玩一下。结果为了安装python3下的pip折腾了一晚上终于工作正常。ubuntu 14.04自带python2.7 和3.4,遂利用apt-get安装pip
sudo apt-get install python3-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
python-pip : Depends: python-setuptools (>= 0.6c1) but it is not going to be installed
Recommends: python-dev-all (>= 2.6) but it is not installable
E: Unable to correct problems, you have held broken packages
sudo apt-get install python3 -setuptools
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
python-setuptools : Depends: python-pkg-resources (= 3.3-1ubuntu1) but 3.3-1ubuntu2 is to be installed
E: Unable to correct problems, you have held broken packages.
既然提示很明确就继续装呗
sudo apt-get install python-pkg-resources=3.3-1ubuntu1
sudo apt-get install python-setuptools
终于不再报错了,安装pip也正常,并且成功安装了djongo。可是无意间用pip3 freeze 时竟然抛错,而且除了install 其他的几乎都不工作。
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/list.py", line 80, in run
self.run_listing(options)
File "/usr/lib/python2.7/dist-packages/pip/commands/list.py", line 142, in run_listing
self.output_package_listing(installed_packages)
File "/usr/lib/python2.7/dist-packages/pip/commands/list.py", line 151, in output_package_listing
if dist_is_editable(dist):
File "/usr/lib/python2.7/dist-packages/pip/util.py", line 348, in dist_is_editable
req = FrozenRequirement.from_dist(dist, [])
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 236, in from_dist
assert len(specs) == 1 and specs[0][0] == '=='
AssertionError
这下有点蒙,搜了一下说是因为pip版本太老,需要升级版本,那就升呗。没想到又是一个大坑啊!
sudo pip3 install --upgrade pip
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/pkg_resources/__init__.py", line 654, in _build_master
ws.require(__requires__)
File "/usr/local/lib/python3.4/dist-packages/pkg_resources/__init__.py", line 968, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/local/lib/python3.4/dist-packages/pkg_resources/__init__.py", line 859, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (pip 9.0.1 (/usr/local/lib/python3.4/dist-packages), Requirement.parse('pip==7.1.0'))
sudo python -m pip install --upgrade --force-reinstall pip