0

I’m using Ubuntu Mate:

Operating System: Ubuntu 16.04.6 LTS

Kernel: Linux 3.4.39-BPI-M3-Kernel

Architecture: arm

I have installed Python 2.7 & 3.5.2 as well as 3.7.7

Wnen I'm trying to install virtualenv error is returned:

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$

If I go with --user flag:

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$

How to handle that?

1

Looks like the lsb_release command is missing, you can install it using apt:

sudo apt install lsb-release
| improve this answer | |
  • Unfortunatelly it doesn't help.It seams I have already installed that: 'pi@bpi-iot-ros-ai:~$ sudo apt install lsb-release [sudo] password for pi: Reading package lists... Done Building dependency tree Reading state information... Done lsb-release is already the newest version (9.20160110ubuntu0.2). The following package was automatically installed and is no longer required: libreadline5 Use 'sudo apt autoremove' to remove it. 0 upgraded, 0 newly installed, 0 to remove and 54 not upgraded. ' And after that when trying to install virtualenv the same error is returned. – zawier May 17 at 23:13
  • lsb_release is /usr/bin/lsb_release – zawier May 17 at 23:17
  • Indeed, so this would mean that /usr/bin/ is not in PATH. – Didier May 18 at 19:59
  • My guess would be that the virtualenv script changed your working directory, and that /usr/bin/ is not in your PATH (if it was, lsb_release would work from anywhere). What does echo $PATH prints ? – Didier May 18 at 20:17
  • /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin – zawier May 18 at 23:49
0

Thank you Didier! There was a solution under the link which you provided. So basically I have python 2.7; 3.5 and 3.7. Solution for me was the same as Jerry Isdale had:

after installing python3.7.3 and changing the symbolic link of python3 to point to it, I had this error. Fixed it by changing first line to

!/usr/bin/python3.5 -Es the original was almost that... had to add the ".5" only.

So done:

$ sudo nano /usr/bin/lsb_release

and changed the first line to:

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

And sudo pip3 install virtualenv went smoothly this time :)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.