zsh command cannot found pip

时光总嘲笑我的痴心妄想 提交于 2020-07-16 23:25:34

问题


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

回答1:


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.




回答2:


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




回答3:


For me it's working to do

python -m pip install [package_name]

instead of

pip install [package_name]



回答4:


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>


来源:https://stackoverflow.com/questions/42870537/zsh-command-cannot-found-pip

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!