zsh command cannot found pip

前端 未结 5 1700
没有蜡笔的小新
没有蜡笔的小新 2020-12-25 10:19

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 plu

5条回答
  •  爱一瞬间的悲伤
    2020-12-25 10:48

    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 
    

提交回复
热议问题