As for me. I hava several python version in my OS.
When i run pip2 -v
, it shows
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 567, in _build_master
ws.require(__requires__)
File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 884, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 775, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (pip 20.3.4 (/usr/local/lib/python3.5/dist-packages), Requirement.parse('pip==8.1.1'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/pip2", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 3238, in <module>
@_call_aside
File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 3222, in _call_aside
f(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 3251, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 569, in _build_master
return cls._build_from_requirements(__requires__)
File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 582, in _build_from_requirements
dists = ws.resolve(reqs, Environment())
File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 770, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pip==8.1.1' distribution was not found and is required by the application
It shows that it find pip version in python3.5
directroy, so I think it maybe the multi version problem.
So i execute ls -l /usr/bin/ |grep python
, it shows that
lrwxrwxrwx 1 root root 26 Aug 16 2019 dh_pypy -> ../share/dh-python/dh_pypy
-rwxr-xr-x 1 root root 1056 Nov 24 2017 dh_python2
lrwxrwxrwx 1 root root 29 Aug 16 2019 dh_python3 -> ../share/dh-python/dh_python3
lrwxrwxrwx 1 root root 23 Mar 2 2021 pdb2.7 -> ../lib/python2.7/pdb.py
lrwxrwxrwx 1 root root 23 Jan 27 2021 pdb3.5 -> ../lib/python3.5/pdb.py
lrwxrwxrwx 1 root root 31 Oct 25 2021 py3versions -> ../share/python3/py3versions.py
lrwxrwxrwx 1 root root 26 Aug 16 2019 pybuild -> ../share/dh-python/pybuild
lrwxrwxrwx 1 root root 24 Aug 11 07:16 python -> /etc/alternatives/python
lrwxrwxrwx 1 root root 9 Nov 24 2017 python2 -> python2.7
-rwxr-xr-x 1 root root 3492624 Mar 2 2021 python2.7
lrwxrwxrwx 1 root root 33 Mar 2 2021 python2.7-config -> x86_64-linux-gnu-python2.7-config
lrwxrwxrwx 1 root root 16 Nov 24 2017 python2-config -> python2.7-config
lrwxrwxrwx 1 root root 9 Oct 25 2021 python3 -> python3.5
-rwxr-xr-x 2 root root 4456208 Jan 27 2021 python3.5
lrwxrwxrwx 1 root root 33 Jan 27 2021 python3.5-config -> x86_64-linux-gnu-python3.5-config
-rwxr-xr-x 2 root root 4456208 Jan 27 2021 python3.5m
lrwxrwxrwx 1 root root 34 Jan 27 2021 python3.5m-config -> x86_64-linux-gnu-python3.5m-config
lrwxrwxrwx 1 root root 16 Mar 23 2016 python3-config -> python3.5-config
lrwxrwxrwx 1 root root 10 Oct 25 2021 python3m -> python3.5m
lrwxrwxrwx 1 root root 17 Mar 23 2016 python3m-config -> python3.5m-config
lrwxrwxrwx 1 root root 16 Nov 24 2017 python-config -> python2.7-config
lrwxrwxrwx 1 root root 29 Nov 24 2017 pyversions -> ../share/python/pyversions.py
-rwxr-xr-x 1 root root 2909 Mar 2 2021 x86_64-linux-gnu-python2.7-config
lrwxrwxrwx 1 root root 34 Jan 27 2021 x86_64-linux-gnu-python3.5-config -> x86_64-linux-gnu-python3.5m-config
-rwxr-xr-x 1 root root 3185 Jan 27 2021 x86_64-linux-gnu-python3.5m-config
lrwxrwxrwx 1 root root 33 Mar 23 2016 x86_64-linux-gnu-python3-config -> x86_64-linux-gnu-python3.5-config
lrwxrwxrwx 1 root root 34 Mar 23 2016 x86_64-linux-gnu-python3m-config -> x86_64-linux-gnu-python3.5m-config
lrwxrwxrwx 1 root root 33 Nov 24 2017 x86_64-linux-gnu-python-config -> x86_64-linux-gnu-python2.7-config
In my case, I want my pip2 work well, so I need make /usr/bin/python
is python2.
so I do sudo mv /usr/bin/python /usr/bin/python_bak
and sudo cp /usr/bin/python2 /usr/bin/python
Then pip2 works well.
Don't forget mv python_bak python
to recover.
Sorry for my poor english.