1

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
  • 42,315
  • 7
  • 94
  • 147
SteveC
  • 53
  • 8
  • 1
    `/usr/bin/python` typically indicates Python 2 usage. There will be no python 'folder' in `/usr/bin`. However, you should start by using python 3. Run `sudo apt install python-is-python3` first, then try and execute your program/code. – Thomas Ward Jun 30 '22 at 22:55
  • 2
    @SteveC The `python-is-python3` package creates a symlink from `/usr/bin/python3` to `/usr/bin/python`. Without this package installed, you will get a "bad interpreter / file not found" error unless you manually create a symlink. See the answer below. – mchid Jul 01 '22 at 00:04
  • 1
    I added an EDIT to the answer to reinstall powerline-shell. The issue is [referenced here](https://bbs.archlinux.org/viewtopic.php?id=250834). – mchid Jul 01 '22 at 07:21

1 Answers1

2

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
  • 42,315
  • 7
  • 94
  • 147
  • For that error, run: `sudo dpkg-reconfigure libdvd-pkg` and then try to reinstall python-is-python3 by running: `sudo apt update` and `sudo apt install --reinstall python-is-python3` You can read more about the libdvd-pkg error [here](https://askubuntu.com/questions/1094062/libdvd-pkg-apt-get-check-failed-you-may-have-broken-packages-aborting) or you can just run the command and it should fix it. – mchid Jul 01 '22 at 06:51
  • @SteveC This doesn't really look like the result of a kernel update. How did you install powerline-shell? Did you use `pip install powerline-shell` or did you use the git method? – mchid Jul 01 '22 at 06:55
  • @SteveC Yeah, just edit your question and post it there. It's much easier to read that way. – mchid Jul 01 '22 at 06:58
  • 1
    done. thank you for helping – SteveC Jul 01 '22 at 07:08
  • Thank you your instructions semed to have fixed the problem! – SteveC Jul 01 '22 at 07:51
  • @SteveC Hey, awesome. Don't forget to click the checkmark icon to the left to mark this as the accepted answer. – mchid Jul 01 '22 at 07:52