pip3 安装 virtualenv 失败

pip3 安装 virtualenv 失败

我正在使用 Ubuntu Mate:

操作系统:Ubuntu 16.04.6 LTS

内核:Linux 3.4.39-BPI-M3-Kernel

架构: arm

我已经安装了 Python 2.7 & 3.5.2 以及 3.7.7

当我尝试安装 virtualenv 时返回错误:

pi@bpi-iot-ros-ai:/usr/bin$ pip3 install virtualenv Defaulting to user
installation because normal site-packages is not writeable ERROR:
Exception: Traceback (most recent call last):   File
"/usr/local/lib/python3.7/site-packages/pip/_internal/cli/base_command.py",
line 188, in _main
    status = self.run(options, args)   File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py",
line 185, in wrapper
    return func(self, options, args)   File "/usr/local/lib/python3.7/site-packages/pip/_internal/commands/install.py",
line 278, in run
    session = self.get_default_session(options)   File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py",
line 83, in get_default_session
    self._session = self.enter_context(self._build_session(options))   File
"/usr/local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py",
line 100, in _build_session
    index_urls=self._get_index_urls(options),   File "/usr/local/lib/python3.7/site-packages/pip/_internal/network/session.py",
line 249, in __init__
    self.headers["User-Agent"] = user_agent()   File "/usr/local/lib/python3.7/site-packages/pip/_internal/network/session.py",
line 132, in user_agent
    zip(["name", "version", "id"], distro.linux_distribution()),   File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py",
line 125, in linux_distribution
    return _distro.linux_distribution(full_distribution_name)   File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line
681, in linux_distribution
    self.version(),   File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line
741, in version
    self.lsb_release_attr('release'),   File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line
903, in lsb_release_attr
    return self._lsb_release_info.get(attribute, '')   File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line
556, in __get__
    ret = obj.__dict__[self._fname] = self._f(obj)   File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line
1014, in _lsb_release_info
    stdout = subprocess.check_output(cmd, stderr=devnull)   File "/usr/local/lib/python3.7/subprocess.py", line 411, in check_output
    **kwargs).stdout   File "/usr/local/lib/python3.7/subprocess.py", line 512, 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/local/bin/pip3", line
10, in <module>
    sys.exit(main())   File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/main.py",
line 75, in main
    return command.main(cmd_args)   File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/base_command.py",
line 114, in main
    return self._main(args)   File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/base_command.py",
line 226, in _main
    self.handle_pip_version_check(options)   File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py",
line 155, in handle_pip_version_check
    timeout=min(5, options.timeout)   File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py",
line 100, in _build_session
    index_urls=self._get_index_urls(options),   File "/usr/local/lib/python3.7/site-packages/pip/_internal/network/session.py",
line 249, in __init__
    self.headers["User-Agent"] = user_agent()   File "/usr/local/lib/python3.7/site-packages/pip/_internal/network/session.py",
line 132, in user_agent
    zip(["name", "version", "id"], distro.linux_distribution()),   File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py",
line 125, in linux_distribution
    return _distro.linux_distribution(full_distribution_name)   File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line
681, in linux_distribution
    self.version(),   File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line
741, in version
    self.lsb_release_attr('release'),   File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line
903, in lsb_release_attr
    return self._lsb_release_info.get(attribute, '')   File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line
556, in __get__
    ret = obj.__dict__[self._fname] = self._f(obj)   File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line
1014, in _lsb_release_info
    stdout = subprocess.check_output(cmd, stderr=devnull)   File "/usr/local/lib/python3.7/subprocess.py", line 411, in check_output
    **kwargs).stdout   File "/usr/local/lib/python3.7/subprocess.py", line 512, in run
    output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.
pi@bpi-iot-ros-ai:/usr/bin$

如果我使用 --user 标志:

pi@bpi-iot-ros-ai:/usr/bin$ pip3 install virtualenv --user
ERROR: Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 188, in _main
    status = self.run(options, args)
  File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 185, in wrapper
    return func(self, options, args)
  File "/usr/local/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 278, in run
    session = self.get_default_session(options)
  File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 83, in get_default_session
    self._session = self.enter_context(self._build_session(options))
  File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 100, in _build_session
    index_urls=self._get_index_urls(options),
  File "/usr/local/lib/python3.7/site-packages/pip/_internal/network/session.py", line 249, in __init__
    self.headers["User-Agent"] = user_agent()
  File "/usr/local/lib/python3.7/site-packages/pip/_internal/network/session.py", line 132, in user_agent
    zip(["name", "version", "id"], distro.linux_distribution()),
  File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 125, in linux_distribution
    return _distro.linux_distribution(full_distribution_name)
  File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 681, in linux_distribution
    self.version(),
  File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 741, in version
    self.lsb_release_attr('release'),
  File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 903, in lsb_release_attr
    return self._lsb_release_info.get(attribute, '')
  File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 556, in __get__
    ret = obj.__dict__[self._fname] = self._f(obj)
  File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 1014, in _lsb_release_info
    stdout = subprocess.check_output(cmd, stderr=devnull)
  File "/usr/local/lib/python3.7/subprocess.py", line 411, in check_output
    **kwargs).stdout
  File "/usr/local/lib/python3.7/subprocess.py", line 512, 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/local/bin/pip3", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/main.py", line 75, in main
    return command.main(cmd_args)
  File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 114, in main
    return self._main(args)
  File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 226, in _main
    self.handle_pip_version_check(options)
  File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 155, in handle_pip_version_check
    timeout=min(5, options.timeout)
  File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 100, in _build_session
    index_urls=self._get_index_urls(options),
  File "/usr/local/lib/python3.7/site-packages/pip/_internal/network/session.py", line 249, in __init__
    self.headers["User-Agent"] = user_agent()
  File "/usr/local/lib/python3.7/site-packages/pip/_internal/network/session.py", line 132, in user_agent
    zip(["name", "version", "id"], distro.linux_distribution()),
  File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 125, in linux_distribution
    return _distro.linux_distribution(full_distribution_name)
  File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 681, in linux_distribution
    self.version(),
  File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 741, in version
    self.lsb_release_attr('release'),
  File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 903, in lsb_release_attr
    return self._lsb_release_info.get(attribute, '')
  File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 556, in __get__
    ret = obj.__dict__[self._fname] = self._f(obj)
  File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 1014, in _lsb_release_info
    stdout = subprocess.check_output(cmd, stderr=devnull)
  File "/usr/local/lib/python3.7/subprocess.py", line 411, in check_output
    **kwargs).stdout
  File "/usr/local/lib/python3.7/subprocess.py", line 512, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.
pi@bpi-iot-ros-ai:/usr/bin$

如何处理?

答案1

看起来lsb_release缺少命令,您可以使用以下命令安装它apt

sudo apt install lsb-release

答案2

谢谢 Didier!下面有一个解决方案链接您提供的。所以基本上我有 Python 2.7;3.5 和 3.7。我的解决方案与 Jerry Isdale 的相同:

在安装 python3.7.3 并更改 python3 的符号链接以指向它之后,我遇到了这个错误。通过将第一行更改为

!/usr/bin/python3.5 -Es原文几乎就是这样...只需添加“.5”。

就这样完成了:

$ sudo nano /usr/bin/lsb_release

并将第一行改为:

#!/usr/bin/python3.5 -Es

这次一切sudo pip3 install virtualenv顺利:)

相关内容