pip: bad interpreter: /../ no such file or directory - python

I can't use pip I get an error
pip: bad interpreter: /Applications/Xcode.app/Contents/Developer/usr/bin/python3: no such file or directory
I try:
brew link --overwrite python
python3 -m pip install whatever
brew install python
brew postinstall python
but nothing works.

somehow python3 cmd is messed up in system by you. you need to reset it.
just run the command
set python3=/usr/bin/python3
now you can use pip

Related

issue when attempting to install python library using pip [duplicate]

How can I use pip in oh-my-zsh? I was trying to install nltk through pip, but it told me zsh: command not found: pip. When I check plugins under .oh-my-zsh/custom/plugins, there is a folder named pip. I don't know what the problem is.
Edit:
$ echo $PATH
/home/xxx/bin:/usr/local/bin:/home/xxx/bin:/home/xxx/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
$ type pip
pip is an alias for noglob pip
Maybe you have installed both python2 and python3. python3 may have been installed later.
You may try to use pip3 instead of pip.
First, input the command:
pip3 -V
If you see the version, the pip3 can be used.
Then you can input command line to install nltk:
pip3 install nltk
I got a way to help you use pip in zsh. We can use nano to edit files. In nano, ctrl+X to save and exit
In the ~ directory, input the command:
nano .bash_profile
You may see some codes like:
# Setting PATH for Python 3.5
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}"
export PATH
Copy them and paste them to the end of .zshrc file by using command:
nano .zshrc
Then input the command:
pip -V
If you see the version, pip can be used.
In case you do
which pip
and it doesn't show the path, just do
which pip3
This will print the path which is /usr/local/bin/pip3
Then do open ~/.zshrc or nano ~/.bash_profile.
Make alias for pip like:
alias pip=/usr/local/bin/pip3
N.B: You copy that line above and paste in your .zshrc file.
After do source ~/.zshrc and close .zshrc
For me it's working to do
python -m pip install [package_name]
instead of
pip install [package_name]
If you installed python3.x, you should run with pip3(not pip)
So you are using oh-my-zsh framework for zsh or Z shell.
First, try the command:
pip3 -V
If you get something like this below, that means you have the pip3 package already and must be having python3 as well.
pip 22.0.4 from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip (python 3.10)
Then edit your .zprofile instead of .bashprofile as you are using zsh. This is the command.
nano ~/.zprofile
Then it should have the two alias like this.
# Setting PATH for Python 3.10
# The original version is saved in .zprofile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.10/bin:${PATH}"
export PATH
alias python=python3
alias pip=pip3
Make sure you save it. Exit and Re-open you terminal. Type the command:
pip -V
It should have the same result as the pip3 -V like this:
❯ pip -V
pip 22.0.4 from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip (python 3.10)
Then you can use pip or pip3 interchangeably for installing your nltk package like this.
pip install nltk
I'm on MacOS and use ZSH. It seems pip 2.7 can't be found, although it is installed. I believe my paths to "pip" are linked wrong (I also have python3 and pip3 installed via brew).
To get around the issue I created an alias. If you don't have an .aliases file, create one in your homedir. Then open the file:
nano ~/.aliases
and add:
## PIP for python2.7 ##
alias pip="python -m pip "
You need to tell ZSH to pick up the alias file (assuming you don't have this setup already). Open your .zshrc:
nano ~/.zshrc
The add the following near the bottom of the file:
[ -f "$HOME/.aliases" ] && source "$HOME/.aliases"
From the terminal, run:
source ~/.zshrc
Or quit your terminal and reopen it.
Now you can run:
pip install <command>
Edit your rc file:
vim ~/.zshrc
Find the config plugins and delete the pip entry.
In a new terminal:
which pip
This will show you the real path of pip
If you're running into this issue, it probably is due to versioning complications. Python 2 versus Python 3 on your OS may be resolving unexpectedly. Below is a quick workaround to get you to functioning behavior.
Try using the below for Python 2:
python -m pip install <command>
Try using the below for Python 3:
pip3 install <command>
In my case my OS was Ubuntu 20.04 and the pip doesn't come with python.
So, i've installed pip through the command
sudo apt install python3-pip
and I'm done.
To ensure run pip -V or pip3 -V
My pip script is missing for some reason, so I have to install it.
$ python -m ensurepip --upgrade
More methods can be found here:pip installation
You should consider upgrading.
Enter this in your terminal
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10 -m pip install --upgrade pip
and then...
Type: pip -V

zsh: /usr/local/bin/pipenv: bad interpreter: /usr/local/opt/python/bin/python3.7: no such file or directory

I recently switched from bash to zsh (MacOS). I haven't used pipenv since the switch. Now when I run any pipenv command I get the following error:
$ pipenv install
zsh: /usr/local/bin/pipenv: bad interpreter: /usr/local/opt/python/bin/python3.7: no such file or directory
I use pyenv for Python dependency management:
$ which python
/Users/ryan.payne/.pyenv/shims/python
My default python version is 3.7.3:
$ pyenv versions
system
2.7.16
3.6.8
* 3.7.3 (set by /Users/ryan.payne/.pyenv/version)
It seems like pipenv is not using my pyenv version of Python. How do I get pipenv working again?
You don't need to uninstall anything. Simply change the interpreter at /usr/local/bin and have your current python path in pyenv handy:
type python3
copy the path
vi /usr/local/bin/pipenv
It will look something like this:
Once it's changed, you will probably have to download pipenv again. Don't worry, your env is fine.
pip install pipenv
Go play in your env
I had this same error with awscli. The solution was to install python#3.7 via homebrew and then cp that installation into the directory awscli expected.
brew install python#3.7
cp -r /usr/local/opt/python#3.7/bin/python3.7 /usr/local/opt/python/bin/python3.7
Run in terminal:
brew install python3 && cp /usr/local/bin/python3 /usr/local/bin/python
After brew installation, sometimes it may not work.
Depending on whether you tried to install other python versions, the links might not be working any more, and therefore running the command
brew install python3 && cp /usr/local/bin/python3 /usr/local/bin/python
Might give an error as below
Error: Could not symlink bin/2to3
Target /usr/local/bin/2to3
already exists.
Try to remove the file 2to3
rm '/usr/local/bin/2to3'
and run the above code again
Alternatively, you can force the linkage
brew link --overwrite python#<version>
but you can first see the files that will be deleted by this forced linking using the command
brew link --overwrite --dry-run python#<version>
I hope this gives more light
If you installed pipenv with pipenv with pipx, then you can reinstall pipenv via pipx reinstall pipenv which should detect any top level changes in your python environment.

pip - No module named 'pip' even after successful installation

I am trying to install pip on my Windows 10 system. I got the get-pip.py file and ran the command
python get-pip.py
Here's a snapshot of the terminal
$ python get-pip.py
Collecting pip
Using cached
https://files.pythonhosted.org/packages/46/dc/7fd5df840e
fb3e56c8b4f768793a237ec4ee59891959d6a215d63f727023/pip-19.0.1-py2
.py3-none-any.whl
Collecting setuptools
Using cached
https://files.pythonhosted.org/packages/ff/47/1dfa4795e
24fd6f93d5d58602dd716c3f101cfd5a77cd9acbe519b44a0a9/wheel-0.32.3-py2.py3-
none-any.whl
Installing collected packages: pip, setuptools, wheel
Successfully installed pip-19.0.1 setuptools-40.8.0 wheel-0.32.3
Now when I try to check the version with
pip -V
I get this -
Traceback (most recent call last):
File "runpy.py", line 193, in _run_module_as_main
File "runpy.py", line 85, in _run_code
File "C:\Program Files\Python\python-3.6.3-embed-
amd64\Scripts\pip.exe\__main__.py", line 5, in <module>
ModuleNotFoundError: No module named 'pip'
Why is this happening? It JUST said pip installed successfully and when I try to see the version to check if its installed, it says No module named 'pip'
Also, I have included C:/Program/Files/Python/python3/Scripts in the PATH variable.
Please help ! ! ! !
After running python get-pip.py, python install-dir will increase dir Lib\site-packages
Method 1. try to cp the pip dir into the python install-dir
or
Method 2. change file python3x._pth in python install-dir,append this line Lib\site-packages
run pip, problem will be solved
Open python37._pth file which is in the root folder of python.
Add Lib\site-packages line.
All will work fine.
The following steps may be followed to install pip on windows:
Download python file: get-pip.py (nearly 1.8 MB size) from link: https://pip.pypa.io/en/stable/installing/#installing-with-get-pip-py and save it to your desktop
Go to command prompt and Check your python version: c:> python
From command prompt run: c:> python get-pip.py
The above will install new version of pip. check by running C:> pip --version
You may also update setup tools - C:> pip install --upgrade pip setuptools
I suggest referring to the pip homepage: https://pip.pypa.io/en/stable/installation/
It describes all methods on how to install pip.
I am a win10 user so the solution was to run this command:
py -m ensurepip --upgrade
Use following commands can be used to find out whether pip extraction path is included or not.
>>> import sys
>>> sys.path
if Lib\site-packages path is not included then update file python37._pth.
Run the command again and path should be visible.
pip install <module name> worked successfully for me after this.
Thanks #demianzhang for the hint or even for the solution.
I found files in my Windows lib\site-packages directory
~ip
~ip-20-0.2.dist-info
Renamed them to
pip
pip-20-0.2.dist-info
And it worked to run pip install --upgrade pip
If your Python environment does not have pip installed, there are 2
mechanisms to install pip supported directly by pip’s maintainers:
ensurepip
get-pip.py
Method 1
ensurepip
Python comes with an ensurepip module1, which can install
pip in a Python environment.
Linux: python -m ensurepip --upgrade
MacOc: python -m ensurepip --upgrade
Windows: py -m ensurepip --upgrade
Method 2
get-pip.py This is a Python script that uses some bootstrapping logic
to install pip.
Download the script, from https://bootstrap.pypa.io/get-pip.py.
Open a terminal/command prompt, cd to the folder containing the
get-pip.py file and run:
Linux: python get-pip.py
MacOc: python get-pip.py
Windows: py get-pip.py
Above installation commands are in official python link.
Optional
After successful installation of pip you might want to upgrade pip to latest version
for Linux and MacOs python -m pip install --upgrade pip
for Windows : py -m pip install --upgrade pip
py -m ensurepip --upgrade
this is work for me official docs link you can try multiple methods based on os.
https://pip.pypa.io/en/stable/installation/
I solved my problem by opening my shell as admin

Python3 running on Mac but no Pip3?

I need to get pip3 running on my Mac terminal for a project. I have python3 installed, and I can run it, but when I try to run pip3 freeze, it says my command is not found.
I thought it would be automatically installed when I installed Python3. I tried to sudo install it, but it still didn't do anything. What can I do?
Besides brew install pip3, in case brew is not installed on your Mac, you can install pip3 via get_pip.py which can be found here. Assuming that python3 is already installed, cd to the directory where you saved get_pip.py and run the file with python3 get_pip.py. This should get pip3 installed on your machine.
On my MacBook Pro (10.13.5), which pip3 shows that it is located at /opt/local/bin/pip3 but it is a symlink to /opt/local/Library/Frameworks/Python.framework/Versions/3.6/bin/pip3.
This is the location of python3 if you installed it via MacPorts. If you installed it with HomeBrew, then it would be /usr/local/Cellar/python/3.7.0/bin/pip3 (again, version might vary).
Finding pip3
What I would do if I were you is first find out where your pip3 actually is by either using locate or trying to manually find it by typing (Change 3.6 to whatever version you're on.) either:
$ /opt/local/Library/Frameworks/Python.framework/Versions/3.6/bin/pip3 --version
or:
$ /usr/local/Cellar/python/3.7.0/bin/pip3 --version
You should see something like:
pip 9.0.3 from /opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (python 3.6)
Otherwise, use locate:
$ locate pip3
As a last resort, the slow find can also be useful:
$ sudo find / -name pip3
Build a Symlink
Then, make a symbolic link to that file in a path that is in your $PATH (again, ensure you replace the first path with the path to your actual pip3):
$ sudo ln -s /opt/local/Library/Frameworks/Python.framework/Versions/3.6/bin/pip3 /opt/local/bin/pip3
Assuming you are using Python 3.4 or later in which pip is included by default, try the following command:
python3 -m pip freeze
When you use the -m command-line flag, python will search sys.path for the named module and execute its contents as the __main__ module. (more here)
This solution will allow you to use pip by python3 -m pip, but in order to use pip3 directly you can:
Install it via Homebrew:
brew install pip3
Install it with get-pip.py:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
You could try brew install pip3. Or check where pip is installed, that might point to Python 3's version.

error when trying to install pip on mac 10.7

I am trying to download pip onto my mac by following the instructions on the pip installation guide and I am coming up with this error after running the following command
$python get-pip.py
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/
MacOS/Python: can't open file 'get-pip.py': [Errno 2] No such file or directory
This is happening after I download the 'get-pip.py' doc as the instructions suggest. Do I need to put this file in a certain location before I continue? I am relatively new to downloading programs through the terminal.
Thanks for the help!
It is recommended (highly) that you NOT use the version of Python that ships with your Mac. Instead use HomeBrew and install a "custom" version of Python (usually the latest). Then proceed to use virtualenv and optionally virtualenvwrapper
Prerequisites:
First, install Xcode from the App Store (it's FREE).
Install HomeBrew:
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
Install Python:
brew install python
This will install pip for you as well in /usr/local/bin/.
Install virtualenv:
pip install virtualenv
virtualenv Basic Usage:
virtualenv /path/to/my/env
cd /path/to/my/env
source ./bin/activate
# hack on your python project
deactivate # to go back to your normal shell
Please follow instructions for virtualenv for more details.
virtualenvwrapper is also really convenient and worthwhile learning.
Update :
More explanation at #dval 's comment
$ curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
and then execute
$ python get-pip.py
None of the above solutions worked for me, so I decided to straight out clean install Python 3.6 from the downloads page at python.org.
After you have completed the Python installer, go into Terminal and type in:
curl -O https://bootstrap.pypa.io/get-pip.py
Wait for the download to complete and then type in:
python3 get-pip.py --user
Then for your pip commands you will use 'pip3'. For example:
pip3 install awsebcli --upgrade --user
After python and pip have been installed they should be in your user Library. So update your PATH in terminal like so:
export PATH=~/Library/Python/3.6/bin:$PATH
I have a bash_profile shell so I also ran the following command in terminal to load script into my current session:
source ~/.bash_profile
After this, verify that your pip installed component was successful.
For example:
eb --version
See AWS for the above reference.
Curl did not work for me. I had to use "wget".
$ wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py
and then execute
$ python get-pip.py

Categories

Resources