3

When I tried to open terminal today to force an update of Firefox, this message comes up in Terminal:

bash: /usr/local/bin/powerline-shell: /usr/bin/python: bad interpreter: No such file or directory
Ubuntu ver 22.04 lts 64 bit

Now after trying to reinstall Python 3 this is what appears

sudo apt install --reinstall python-is-python3
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 3 not upgraded.
Need to get 2,788 B of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu jammy/main amd64 python-is-python3 all 3.9.2-2 [2,788 B]
Fetched 2,788 B in 1s (4,161 B/s)             
(Reading database ... 420664 files and directories currently installed.)
Preparing to unpack .../python-is-python3_3.9.2-2_all.deb ...
Unpacking python-is-python3 (3.9.2-2) over (3.9.2-2) ...
Setting up python-is-python3 (3.9.2-2) ...
Processing triggers for man-db (2.10.2-1) ...
/usr/lib/python3/dist-packages/pkg_resources/__init__.py:116: PkgResourcesDeprecationWarning: 1.16.0-unknown is an invalid version and will not be supported in a future release
  warnings.warn(
/usr/lib/python3/dist-packages/pkg_resources/__init__.py:116: PkgResourcesDeprecationWarning: 0.1.43ubuntu1 is an invalid version and will not be supported in a future release
  warnings.warn(
/usr/lib/python3/dist-packages/pkg_resources/__init__.py:116: PkgResourcesDeprecationWarning: 1.1build1 is an invalid version and will not be supported in a future release
  warnings.warn(
Traceback (most recent call last):
  File "/usr/local/bin/powerline-shell", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3267, in <module>
    def _initialize_master_working_set():
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3241, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3279, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 573, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 891, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 777, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'powerline-shell==0.7.0' distribution was not found and is required by the application

When I close and reopen Terminal this is what is displayed:

/usr/lib/python3/dist-packages/pkg_resources/__init__.py:116: PkgResourcesDeprecationWarning: 1.16.0-unknown is an invalid version and will not be supported in a future release
  warnings.warn(
/usr/lib/python3/dist-packages/pkg_resources/__init__.py:116: PkgResourcesDeprecationWarning: 0.1.43ubuntu1 is an invalid version and will not be supported in a future release
  warnings.warn(
/usr/lib/python3/dist-packages/pkg_resources/__init__.py:116: PkgResourcesDeprecationWarning: 1.1build1 is an invalid version and will not be supported in a future release
  warnings.warn(
Traceback (most recent call last):
  File "/usr/local/bin/powerline-shell", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3267, in <module>
    def _initialize_master_working_set():
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3241, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3279, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 573, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 891, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 777, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'powerline-shell==0.7.0' distribution was not found and is required by the application
mchid
  • 44,904
  • 8
  • 102
  • 162
SteveC
  • 73
  • 8

1 Answers1

3

Run the following commands to fix the problem by linking /usr/bin/python to /usr/bin/python3:

sudo apt update
sudo apt install python-is-python3

To explain:

older versions of Ubuntu used Python2 as the default version. Traditionally, /usr/bin/python was linked to /usr/bin/python2 and most scripts explicitly ran /usr/bin/python3 for Python3. A couple of years ago and after the transition to Python3, they left this option up to the user for backwards compatibility.

In earlier versions after the transition, there were two options: python-is-python2 and python-is-python3. Installing either one of these packages would link their respective Python version to /usr/bin/python. Again, this was to ensure backwards compatibility. Since then, Python2 has become somewhat obsolete and it appears that python-is-python3 is now the only option available. Without this package, there is no symlink to /usr/bin/python unless you create one manually.

See this related question for more info.


EDIT:

So, it looks like you have a couple of options to fix this.

First, run the following command to try and uninstall powerline-shell:

sudo pip uninstall powerline-shell

If that works, run the following series of commands to install it locally:

/usr/bin/pip3 install --upgrade pip

Now, log out and log back in and run the following:

pip install powerline-shell

If you still have the powerline-shell problem after you open the terminal, run the following commands:

pip uninstall powerline-shell
git clone https://github.com/b-ryan/powerline-shell
cd powerline-shell
python setup.py install
mchid
  • 44,904
  • 8
  • 102
  • 162