由于系统自带Python3.5,使用Ubuntu16.04安装了Python3.6.5,https://blog.csdn.net/JiekeXu/article/details/80294523,文章链接在此,做了修改后,不管你使用pip还是使用pip3安装包,或者更新包,更或者升级pip,都会报错:
subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.
完整的一个报错如下:
root@ubuntu:/usr/bin/python3.6/bin# python3 -m pip install -U pip
Exception:
Traceback (most recent call last):
File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_internal/basecommand.py", line 228, in main
status = self.run(options, args)
File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_internal/commands/install.py", line 241, in run
with self._build_session(options) as session:
File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_internal/basecommand.py", line 81, in _build_session
insecure_hosts=options.trusted_hosts,
File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_internal/download.py", line 338, in __init__
self.headers["User-Agent"] = user_agent()
File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_internal/download.py", line 101, in user_agent
zip(["name", "version", "id"], distro.linux_distribution()),
File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_vendor/distro.py", line 120, in linux_distribution
return _distro.linux_distribution(full_distribution_name)
File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_vendor/distro.py", line 634, in linux_distribution
self.version(),
File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_vendor/distro.py", line 688, in version
self.lsb_release_attr('release'),
File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_vendor/distro.py", line 836, in lsb_release_attr
return self._lsb_release_info.get(attribute, '')
File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_vendor/distro.py", line 522, in __get__
ret = obj.__dict__[self._fname] = self._f(obj)
File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_vendor/distro.py", line 933, in _lsb_release_info
stdout = subprocess.check_output(cmd, stderr=devnull)
File "/usr/bin/python3.6/lib/python3.6/subprocess.py", line 336, in check_output
**kwargs).stdout
File "/usr/bin/python3.6/lib/python3.6/subprocess.py", line 418, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.
Traceback (most recent call last):
File "/usr/bin/python3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/bin/python3.6/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/__main__.py", line 19, in
sys.exit(_main())
File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_internal/__init__.py", line 246, in main
return command.main(cmd_args)
File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_internal/basecommand.py", line 264, in main
timeout=min(5, options.timeout)) as session:
File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_internal/basecommand.py", line 81, in _build_session
insecure_hosts=options.trusted_hosts,
File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_internal/download.py", line 338, in __init__
self.headers["User-Agent"] = user_agent()
File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_internal/download.py", line 101, in user_agent
zip(["name", "version", "id"], distro.linux_distribution()),
File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_vendor/distro.py", line 120, in linux_distribution
return _distro.linux_distribution(full_distribution_name)
File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_vendor/distro.py", line 634, in linux_distribution
self.version(),
File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_vendor/distro.py", line 688, in version
self.lsb_release_attr('release'),
File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_vendor/distro.py", line 836, in lsb_release_attr
return self._lsb_release_info.get(attribute, '')
File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_vendor/distro.py", line 522, in __get__
ret = obj.__dict__[self._fname] = self._f(obj)
File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_vendor/distro.py", line 933, in _lsb_release_info
stdout = subprocess.check_output(cmd, stderr=devnull)
File "/usr/bin/python3.6/lib/python3.6/subprocess.py", line 336, in check_output
**kwargs).stdout
File "/usr/bin/python3.6/lib/python3.6/subprocess.py", line 418, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.
root@ubuntu:/usr/bin/python3.6/bin#
没办法,这个错误解决了好久就是没法解决,终于在网上看到了一个解决方案说明需要删除lsb_release文件可解决此问题
sudo rm /usr/bin/lsb_release
#当然不删除为好
sudo mv /usr/bin/lsb_release /usr/bin/lsb_release_bak1223
具体可参考连接:https://github.com/pypa/pip/issues/4924
This has been fixed in the in-development version of pip. It's due to distro
dropping support for python 2.6, much like pip will in it's next major release.…………