Encountering "-bash: /usr/local/bin/pip3: /usr/bin/python3.6: bad interpreter: No such file or directory" while checking the pip3 version

33,134

Solution 1

  1. Run the command which python3 to show the path to the python3 executable. In the commands in step 2, I am assuming that it is the default which is /usr/bin/python3

  2. Create a symbolic link at /usr/bin/python3.6 which references to file /usr/bin/python3.

    sudo ln -s /usr/bin/python3 /usr/bin/python3.6
    

Solution 2

Type in a terminal (I used the VSCode terminal, because my default terminal with Ctrl + Alt + T won't work).

sudo update-alternatives --config python3

See the terminal output You will be prompted to select the path for your python3, In my case I've selected option number 1 (I want the option that says python3.6 manual mode).

Now everything should work fine (terminal , software update manager, python etc).

Share:
33,134

Related videos on Youtube

fuser
Author by

fuser

Updated on September 18, 2022

Comments

  • fuser
    fuser over 1 year

    I installed pip3 for my current python version

    $ python -V
    Python 3.5.1+
    

    I used this command to install pip3

    sudo apt install python3-pip
    

    When I tried to check out the version of pip

    $ pip3 -V 
    

    I got

    -bash: /usr/local/bin/pip3: /usr/bin/python3.6: bad interpreter: No such file or directory
    

    Previously I had installed python3.6 and deleted it.

    Here is the approval:

    $ sudo apt remove python3.6
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    Package 'python3.6' is not installed, so not removed
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    

    Here is my ${PATH}

    $ echo ${PATH}
    /home/user/.local/share/umake/bin:/home/user/.local/share/umake/bin:/home/user/.local/share/umake/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/snap/bin
    

    How do I fix path for my current pip?

  • fuser
    fuser almost 7 years
    Hi, karel. Thank you for the reply. That's right which python3 has been giving me ==> /usr/bin/python3. But I've got this after trying to create symlink ==> ln: failed to create symbolic link '/usr/bin/python3.6': File exists. Is there other way to fix this? Python is really sophisticated with all it's versions.
  • mchid
    mchid about 4 years
    It should be noted that you should not remove the python 3.6 file if this is the only version of python3 installed on your system or if python3.6 is your default python3 or you may break your system. /usr/bin/python3 is not an actual file, it is a link to your default installed python3 executable.