在终端中运行任何与python相关的命令/程序时出错

时间:2015-09-25 11:05:01

标签: python shell runtime-error

我最近在我的机器上设置了拱形;安装了python。 // type of functions being binary operations typedef int (binary_operation*)(int, int); // now you can define any binary operation on ints int add_op(int a, int b) { // definition }; int mul_op(int a, int b) { // definition }; // main... binary_operation f; if (oper == "+") f = add_op; sum = f(in1,int2); 符号链接到/usr/bin/python/usr/bin/python3本身是/usr/bin/python3.4的符号链接。
因为,我使用python2.7,我继续将pythonpython2.7联系起来 现在,当我尝试python依赖程序时,我收到以下错误。

Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3084, in <module>
@_call_aside
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3070, in _call_aside
f(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3097, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 651, in _build_master
ws.require(__requires__)
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 952, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 839, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pip==7.1.2' distribution was not found and is required by the application

我想知道出了什么问题。

1 个答案:

答案 0 :(得分:2)

pip中的/usr/bin脚本与Python 3.4绑定。小脚本只是一个引导脚本,用于从模块加载实际代码。 Python 2.7中缺少该模块,因为您没有为它安装pip

修复脚本以使用/usr/bin/pythoninstall pip for Python 2.7替换第一行中的/usr/bin/python3

或者,只将/usr/bin/python2链接到Python 2.7并让/usr/bin/python指向Python 3.无论如何,其他Arch程序很可能依赖于Python 3。另请参阅"Proper way" to manage multiple versions of Python on archlinux