Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip3: bad interpreter: No such file or directory

I am trying to install dependencies using pip3 command

current scenario:

Dev$ which python /Users/Dev/anaconda/bin/python  Dev$ which python3 /usr/local/bin/python3   Dev$ pip --version pip 10.0.1 from /usr/local/lib/python2.7/site-packages/pip (python 2.7)  Dev$ pip3 --version -bash: /usr/local/bin/pip3: /usr/local/opt/python3/bin/python3.6: bad  interpreter: No such file or directory 

I have no idea why my pip3 command is not working.

I have tried things like this:

brew link --overwrite python  
like image 532
floss Avatar asked Jul 17 '18 04:07

floss


People also ask

How do I fix pip3 not found?

To Solve sudo: pip3: command not found Error Just use python3 -m pip and this solved my problem. Second solution is Just check pip installed or not with this command pip3 -V If pip is not installed then You would need to install pip3. For Linux Users sudo apt install python3-pip.

How do I download pip3 on Linux?

To install pip3 on Ubuntu or Debian Linux, open a new Terminal window and enter sudo apt-get install python3-pip . To install pip3 on Fedora Linux, enter sudo yum install python3-pip into a Terminal window. You will need to enter the administrator password for your computer in order to install this software.

How do I download pip3 for Mac?

How could I install pip3 on my Mac? To install or upgrade pip, download get-pip.py from the official site Then run the following command: sudo python get-pip.py and it will install the pip for your python version which runs the script.

What is bad interpreter no such file or directory error?

Each of the systems has its own shells which the system will use to execute its own system scripts. We will consider the bad interpreter no such file or directory errors in diverse operating systems such as Ubuntu, Linux, Mac, and Rosrun. This error does occur in the Unix system, Mac system, and also Microsoft Windows system.

What is a bad interpreter in Python?

Whenever your system displays a bad interpreter on such a file or directory, python is unable to interpret or compile the script for execution. This means the python script contains a carriage that returns the character of a different operating system in the code line.

Why is my PIP3 not working in Python 3?

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.

What is the difference between Pip and PIP3?

Situations like this are exactly why running pip or pip3 directly is no longer recommended, in favor of: 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.


2 Answers

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.)

like image 194
abarnert Avatar answered Sep 28 '22 07:09

abarnert


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.

like image 42
A. Attia Avatar answered Sep 28 '22 08:09

A. Attia