简体   繁体   English

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

[英]error while running any python-dependent commands/programs in terminal

I recently set up arch on my machine; 我最近在机器上设置了拱门; installed python. 安装了python。 /usr/bin/python was symlinked to /usr/bin/python3 which itself is a symlink to /usr/bin/python3.4 . /usr/bin/python被符号链接到/usr/bin/python3 ,它本身是/usr/bin/python3.4的符号链接。
Because, I use python2.7, I went ahead and linked python to python2.7 . 因为我使用python2.7,所以我继续将python链接到python2.7
Now when I try to python dependent program, I get the following error. 现在,当我尝试使用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

I wish to know what's gone wrong. 我想知道出了什么问题。

The pip script in /usr/bin is tied to Python 3.4. /usr/binpip脚本与Python 3.4绑定在一起。 The small script is just a bootstrapping script to load the actual code from a module. 小脚本只是一个引导脚本,用于从模块加载实际代码。 That module is missing in Python 2.7 because you did not install pip for it. Python 2.7中缺少该模块,因为您没有为其安装pip

Either fix the script to replace /usr/bin/python in the first line with /usr/bin/python3 , or install pip for Python 2.7 . 修复脚本以将第一行中的/usr/bin/python替换为/usr/bin/python3 ,或者为Python 2.7安装pip

Alternatively, only link /usr/bin/python2 to Python 2.7 and leave /usr/bin/python to point to Python 3. It is quite likely other Arch programs rely on that being Python 3, anyway. 或者,仅将/usr/bin/python2链接到Python 2.7,而让/usr/bin/python指向Python3。无论如何,其他Arch程序很可能都依赖于Python 3。 Also see "Proper way" to manage multiple versions of Python on archlinux . 另请参见“适当的方法”以在archlinux上管理多个版本的Python

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM