简体   繁体   中英

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

I recently set up arch on my machine; installed python. /usr/bin/python was symlinked to /usr/bin/python3 which itself is a symlink to /usr/bin/python3.4 .
Because, I use python2.7, I went ahead and linked python to python2.7 .
Now when I try to python dependent program, I get the following error.

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. 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.

Either fix the script to replace /usr/bin/python in the first line with /usr/bin/python3 , or install pip for Python 2.7 .

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. Also see "Proper way" to manage multiple versions of Python on archlinux .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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