Home > Net >  bash: /home/--------/.local/bin/pip3: /usr/bin/python3: bad interpreter: No such file or directory
bash: /home/--------/.local/bin/pip3: /usr/bin/python3: bad interpreter: No such file or directory

Time:11-01

I recently had my python versions messed up as they weren't there in my /usr/bin. Now I have mostly gotten it fixed so when I type:

------@--------:~$ python3 
Python 3.8.5 (default, Oct 30 2022, 19:55:55)  [GCC 9.4.0] 
on linux Type "help", "copyright", "credits" or "license" for more information.

and when I type:

-----@-------:~$ python 
Python 3.8.5 (default, Oct 30 2022, 19:55:55)  [GCC 9.4.0] 
on linux Type "help", "copyright", "credits" or "license" for more information.

When I use the command pip3 however I get a weird error of:

-----@-------:~$ pip3 
bash: /home/jayakumar/.local/bin/pip3: /usr/bin/python3: bad interpreter: No such file or directory

I was told in another question to use python3 -m pip install instead but I get an even weirder error:

ERROR: Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 188, in _main
    status = self.run(options, args)
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 185, in wrapper
    return func(self, options, args)
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 252, in run
    options.use_user_site = decide_user_install(
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 599, in decide_user_install
    if site_packages_writable(root=root_path, isolated=isolated_mode):
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 544, in site_packages_writable
    test_writable_dir(d) for d in set(get_lib_location_guesses(**kwargs))
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 538, in get_lib_location_guesses
    scheme = distutils_scheme('', *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/locations.py", line 109, in distutils_scheme
    d.parse_config_files()
  File "/usr/local/lib/python3.8/distutils/dist.py", line 406, in parse_config_files
    parser.read(filename)
  File "/usr/local/lib/python3.8/configparser.py", line 697, in read
    self._read(fp, filename)
  File "/usr/local/lib/python3.8/configparser.py", line 1082, in _read
    raise MissingSectionHeaderError(fpname, lineno, line)
configparser.MissingSectionHeaderError: File contains no section headers.
file: 'setup.cfg', line: 1
'<?xml version="1.0" encoding="utf-8"?>\n'
WARNING: You are using pip version 20.1.1; however, version 22.3 is available.
You should consider upgrading via the '/usr/local/bin/python3 -m pip install --upgrade pip' command.

Any thoughts on how to solve this? Also, I tried the /usr/local/bin/python3 -m pip install --upgrade pip suggestion and that bears the same error.

CodePudding user response:

You can see where your pip3 file is:

which pip3

That should tell you the full path, which is /home/jayakumar/.local/bin/pip3

You can view that file like this:

more /home/jayakumar/.local/bin/pip3

In the first line, notice that it has #!/usr/bin/python3 or That directive tells your system where to look for python executable, which is /usr/bin/python3

Seems like you don't have that executable. Looks like /usr/local/bin/python3 is available. You can try switching to that executable. Or you can also reinstall python3: sudo apt install python3 --reinstall

Hope this helps.

  • Related