close

[Solved] pip3: bad interpreter: No such file or directory

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error pip3: bad interpreter: No such file or directory in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How pip3: bad interpreter: No such file or directory Error Occurs?

Today I get the following error pip3: bad interpreter: No such file or directory in python.

How To Solve pip3: bad interpreter: No such file or directory Error ?

  1. How To Solve pip3: bad interpreter: No such file or directory Error ?

    To Solve pip3: bad interpreter: No such file or directory Error You've got a whole slew of different Python installations, plus at least one former Python installation that you deleted.

  2. pip3: bad interpreter: No such file or directory

    To Solve pip3: bad interpreter: No such file or directory Error You've got a whole slew of different Python installations, plus at least one former Python installation that you deleted.

Solution 1

You’ve got a whole slew of different Python installations, plus at least one former Python installation that you deleted.

Situations like this are exactly why running pip or pip3 directly is no longer recommended, in favor of:

python3 -m pip install whatever

This guarantees that you’re absolutely positively running the pip that goes with whatever python3 means, while pip3 just means you’re running the pip that goes with some Python 3.x, which may be any of the various ones you’ve installed.

Or, even better, use virtual environments, so you can rely on the fact that python and pip are the commands from the currently-active environment, and not even worry about what they mean system-wide.


But, if you want to know how you got into this mess and how to fix it:

Your python3 command is probably from a Homebrew Python (you can check; ls -l /usr/local/bin/python3 and see if it’s a symlink to something in /usr/local/Cellar/python).

Your pip3 command is from a Python 3 that doesn’t exist. Most likely, you installed another Python 3, which overwrote the pip3 from the Homebrew Python 3, and then uninstalled it, leaving a broken pip behind.

The simplest thing to do is to just rm /usr/local/bin/pip3. Then, assuming you want your Homebrew Python to be your default for python3 and pip3, redo the brew link python command. If it shows you any warnings or errors, you still have other things to fix. If not, /usr/local/bin/pip3 should now be the Homebrew 3.6 pip, and which pip3 should pick out /usr/local/bin/pip3, and everything is good until the next time you install another Python 3 and overwrite a bunch of stuff.

A better fix would be to pick one way of installing Python—whether Anaconda, Homebrew, python.org installers, or whatever—and use that consistently. Uninstall everything, reinstall the one you actually want, and never touch the others again. (Unfortunately, you will still be stuck with Apple’s system Python 2.7, but if you’re only using 3.x, that won’t matter.)

Solution 2

You can try to change the python version of pip by doing
vim /path/to/pip
Then change the commented line (first line) with the desired version of Python.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read