bash:pip:找不到命令

问题:bash:pip:找不到命令

我下载了pip并运行python setup.py install,一切正常。本教程的下一步是运行,pip install <lib you want>但是甚至在尝试在线查找任何内容之前,我都会收到错误消息“ bash:pip:not found”。

这是在Mac OS X上,这也是我的新手,因此我假设有些路径设置在运行setup.py时未正确设置。我该如何进一步调查?我需要检查什么才能更好地了解问题的确切原因?

编辑:我也尝试过为Mac安装Python 2.7,希望友好的安装过程能够完成所有工作,例如编辑PATH,以及根据教程使一切正常工作所需的其他一切,但这是行不通的。安装运行后,“ python”仍然运行python 2.6,并且PATH未更新。

I downloaded pip and ran python setup.py install and everything worked just fine. The very next step in the tutorial is to run pip install <lib you want> but before it even tries to find anything online I get an error “bash: pip: command not found”.

This is on Mac OS X, which I’m new too, so I’m assuming there’s some kind of path setting that was not set correctly when I ran setup.py. How can I investigate further? What do I need to check to get a better idea of the exact cause of the problem?

EDIT: I also tried installing Python 2.7 for Mac in the hopes that the friendly install process would do any housekeeping like editing PATH and whatever else needs to happy for everything to work according to the tutorials, but this didn’t work. After installing is running ‘python’ still ran Python 2.6 and PATH was not updated.


回答 0

为什么不这样做,sudo easy_install pip或者这是否适用于python 2.6 sudo easy_install-2.6 pip

这将使用默认的python软件包安装程序系统安装pip,并同时为您节省了手动设置的麻烦。

这将允许您运行pippython软件包安装命令,因为它将与系统python一起安装。我也建议您在使用virtualenv软件包和模式时获得点子。:)

Why not just do sudo easy_install pip or if this is for python 2.6 sudo easy_install-2.6 pip?

This installs pip using the default python package installer system and saves you the hassle of manual set-up all at the same time.

This will allow you to then run the pip command for python package installation as it will be installed with the system python. I also recommend once you have pip using the virtualenv package and pattern. :)


回答 1

使用setuptools安装pip

sudo easy_install pip

(我知道答案的上面部分对于klobucar来说是多余的,但是我还不能添加评论),所以这是一个解决方案 sudo: easy_install: command not found关于Debian / Ubuntu:

sudo apt-get install python-setuptools

另外,对于python3,请使用easy_install3python3-setuptools

Use setuptools to install pip:

sudo easy_install pip

(I know the above part of my answer is redundant with klobucar’s, but I can’t add comments yet), so here’s an answer with a solution to sudo: easy_install: command not found on Debian/Ubuntu:

sudo apt-get install python-setuptools

Also, for python3, use easy_install3 and python3-setuptools.


回答 2

首先:尝试使用pip3而不是pip。例:

pip3 --version
pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)

pip3应该与Python3.x一起自动安装。该文档尚未更新,因此例如在安装Flask时,将说明中的pip替换为pip3即可。

现在,如果这不起作用,则可能必须单独安装pip。

First of all: try pip3 instead of pip. Example:

pip3 --version
pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)

pip3 should be installed automatically together with Python3.x. The documentation hasn’t been updated, so simply replace pip by pip3 in the instructions, when installing Flask for example.

Now, if this doesn’t work, you might have to install pip separately.


回答 3

更新:访问正确的pip安装以进行正确的python安装的一种更可靠的现代方法是使用语法python -m pip

原始答案

pip会将其自身安装到您的python安装位置的bin中。它还应创建一个指向更常见位置的符号链接,例如/usr/local/bin/pip

您可以编辑~/.profilePATH并将其更新为include /Library/Frameworks/Python.framework/Versions/2.6/bin,也可以在路径中的已知位置创建指向它的符号链接。

如果您执行以下操作: echo $PATH,您应该看到当前正在搜索的路径。如果/usr/local/bin位于PATH中,则可以执行以下操作:

ln -s /Library/Frameworks/Python.framework/Versions/2.6/bin/pip /usr/local/bin

我会选择将python bin添加到$ PATH变量中。

Update: A more reliable modern way to access the right pip install for the right python install is to use the syntax python -m pip.

Original Answer

pip would install itself into the bin of your python installation location. It also should create a symlink to some more common location like /usr/local/bin/pip

You can either edit your ~/.profile and update your PATH to include /Library/Frameworks/Python.framework/Versions/2.6/bin, or you could create a symlink to it in a place that you know is in your path.

If you do: echo $PATH, you should see the paths currently being searched. If /usr/local/bin is in your PATH, you can do:

ln -s /Library/Frameworks/Python.framework/Versions/2.6/bin/pip /usr/local/bin

I would opt for adding the python bin to your $PATH variable.


回答 4

按照给定安装Python最新版本 这里

它具有许多下载链接,例如numpy和scipy

然后转到终端并输入以下命令:

sudo easy_install pip

对于Python安装包,请检查此

安装软件包的要求本节介绍在安装其他Python软件包之前应遵循的步骤。

安装pip,setuptools和wheel如果从python.org安装了Python 2> = 2.7.9或Python 3> = 3.4,则已经具有pip和setuptools,但需要升级到最新版本:

在Linux或OS X上:

pip install -U pip setuptools在Windows上:

python -m pip install -U pip setuptools如果您正在Linux上使用由系统软件包管理器(例如“ yum”,“ apt-get”等)管理的Python安装,并且您想使用系统软件包管理器要安装或升级pip,请参阅使用Linux软件包管理器安装pip / setuptools / wheel

除此以外:

安全下载get-pip.py 1

运行python get-pip.py。2这将安装或升级点子。另外,如果尚未安装setuptools和wheel,它将安装setuptools和wheel。

Install Python latest version as given here

It has many download links like numpy and scipy

Then go to terminal and enter following command:-

sudo easy_install pip

For Python install packages check this

Requirements for Installing Packages This section describes the steps to follow before installing other Python packages.

Install pip, setuptools, and wheel If you have Python 2 >=2.7.9 or Python 3 >=3.4 installed from python.org, you will already have pip and setuptools, but will need to upgrade to the latest version:

On Linux or OS X:

pip install -U pip setuptools On Windows:

python -m pip install -U pip setuptools If you’re using a Python install on Linux that’s managed by the system package manager (e.g “yum”, “apt-get” etc…), and you want to use the system package manager to install or upgrade pip, then see Installing pip/setuptools/wheel with Linux Package Managers

Otherwise:

Securely Download get-pip.py 1

Run python get-pip.py. 2 This will install or upgrade pip. Additionally, it will install setuptools and wheel if they’re not installed already.


回答 5

我必须承认对python绝对是新手,我只需要一件事:awscli。我在下载python 3.xx时遇到了这个问题-pip:命令未找到

遵循下载AWS CLI的说明后,我进行了更改

pip install awscli

pip3 install awscli

运行了正确的版本。

我在计算机上做了一个别名,以在输入python的同时运行python3,这通常会运行系统版本2.7。我现在不确定这是个好主意。我想我只是按照他们想要的那样输入命令

I have to admit to being absolutely new to python, which I only need for one thing: awscli. I encountered this problem having downloaded python 3.x.x – pip: command not found

Whilst following the instructions for downloading the AWS cli I changed

pip install awscli

to

pip3 install awscli

which ran the correct version.

I’ve made an alias on my machine to run python3 whilst typing python, which would normally run the system version 2.7. I’m not sure this is a good idea now. I think I’ll just type in the commands as they intended them to be


回答 6

请参阅“ 如何安装Pip”一文,以了解更多信息。

截至2019年,

提供下载get-pip.py https://pip.pypa.io使用下面的命令:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

使用以下命令运行get-pip.py:
sudo python get-pip.py

完成安装后,运行此命令以检查是否安装了pip。
pip --version

安装pip后,删除get-pip.py文件。
rm get-pip.py

Check out How to Install Pip article article for more information.

As of 2019,

Download get-pip.py provided by https://pip.pypa.io using the following command:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

Run get-pip.py using the following command:
sudo python get-pip.py

After you done installing, run this command to check if pip is installed.
pip --version

Remove get-pip.py file after installing pip.
rm get-pip.py


回答 7

使用apt-get安装会在整个系统范围内安装pip,而不仅仅是为您的用户安装本地系统。尝试使用此命令使pip在您的系统上运行…

$ sudo apt-get install python-pip python-dev build-essential

然后pip将被安装而没有任何问题,您将可以使用“ sudo pip …”。

Installing using apt-get installs a system wide pip, not just a local one for your user. Try this command to get pip running on your system …

$ sudo apt-get install python-pip python-dev build-essential

Then pip will be installed without any issues and you will be able to use “sudo pip…”.


回答 8

不推荐使用大多数安装PIP的方法。这是最新的(2019)解决方案。请下载get-pip脚本

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

运行脚本

sudo python get-pip.py

Most of the methods to install PIP are deprecated. Here is the latest (2019) solution. Please download get-pip script

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

Run the script

sudo python get-pip.py

回答 9

我花了很长时间浏览本页上的所有答案,但在s-walsh对OP问题的评论中找到了一个对我有用的

答案是使用pip3:

$ pip3 install <name-of-install>

I spent ages going through all the answers on this page but found the one that worked for me in the comments of the OP question by s-walsh

The answer is to use pip3:

$ pip3 install <name-of-install>

回答 10

解决:

  1. 将此行添加到〜/ .bash_profile

    导出PATH =“ / usr / local / bin:$ PATH”

  2. 在终端窗口中,运行

    来源〜/ .bash_profile

To solve:

  1. Add this line to ~/.bash_profile

    export PATH=”/usr/local/bin:$PATH”

  2. In a terminal window, run

    source ~/.bash_profile


回答 11

它可能是root权限。我尝试退出root登录,使用

sudo su -l root
pip <command>

这对我行得通

It might be the root permission. I tried exit root login, use

sudo su -l root
pip <command>

that works for me


回答 12

安装Homebrew,打开Terminal或您喜欢的OSX终端仿真器并运行

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

将Homebrew目录插入PATH环境变量的顶部。您可以通过在〜/ .profile文件底部添加以下行来完成此操作

export PATH=/usr/local/bin:/usr/local/sbin:$PATH

现在,我们可以安装Python 2.7:

$ brew install python

获取点子存储库:

$ git clone https://github.com/pypa/pip

安装点:

$sudo easy_install pip

install Homebrew, open Terminal or your favorite OSX terminal emulator and run

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

insert the Homebrew directory at the top of your PATH environment variable. You can do this by adding the following line at the bottom of your ~/.profile file

export PATH=/usr/local/bin:/usr/local/sbin:$PATH

Now, we can install Python 2.7:

$ brew install python

Get pip repository:

$ git clone https://github.com/pypa/pip

install pip:

$sudo easy_install pip

回答 13

如果您正在运行Python 3.5,请运行以下终端命令:

sudo pip3 install -U nltk

终端中的任何其他pip命令都将类似:

pip3 install --upgrade pip
sudo pip3 install -U numpy ::

If you are running Python 3.5, run the following terminal command:

sudo pip3 install -U nltk

Any other pip commands in terminal would be similar:

pip3 install --upgrade pip
sudo pip3 install -U numpy ::

回答 14

python默认情况下安装它,但如果未安装,则可以使用以下cmd手动安装(仅适用于linux)

对于python3:

sudo apt install python3-pip 

对于python2

sudo apt install python-pip 

希望它的帮助。

python install it by default but if not install you can install it manual use following cmd (for linux only )

for python3 :

sudo apt install python3-pip 

for python2

sudo apt install python-pip 

hope its help.


回答 15

避免sudo

python <(curl https://bootstrap.pypa.io/get-pip.py) --user
echo 'export "PATH=$HOME/Library/Python/2.7/bin:$PATH"' >> ~/.bash_profile

从:

http://www.pip-command-not-found.com

Avoiding sudo:

python <(curl https://bootstrap.pypa.io/get-pip.py) --user
echo 'export "PATH=$HOME/Library/Python/2.7/bin:$PATH"' >> ~/.bash_profile

From:

http://www.pip-command-not-found.com


回答 16

CentOS 7用户可以使用:

yum install python-pip

virtualenv如果您使用的是点子,也建议使用。可以用相同的方式添加它:

yum install python-virtualenv

CentOS 7 users can just use:

yum install python-pip

Also recommend using virtualenv if you’re using pip. It can be added in the same way:

yum install python-virtualenv

回答 17

假设您有互联网,请参阅: https //pip.pypa.io/en/stable/installing/

基本上运行:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

python get-pip.py

assuming you have internet see: https://pip.pypa.io/en/stable/installing/

basically run:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

and

python get-pip.py

回答 18

(上下文:我的操作系统是使用AWS的Amazon linux。它看起来与RedHat类似,但看起来有所减少。)

退出外壳,然后打开一个新的外壳。pip命令现在可以使用。

这就是解决此位置问题的方法。

您可能还想知道:然后需要像下面的示例(例如jupyter)那样编写用于安装软件的pip命令,以便在我的系统上正常工作:

pip安装jupyter –user

具体来说,请注意缺少sudo以及–user的存在

如果pip文档对所有这些都说了话,那将是非常不错的,但是我猜这将需要输入更多的字符。

(Context: My OS is Amazon linux using AWS. It seems similar to RedHat but it’s stripped down a bit, it seems.)

Exit the shell, then open a new shell. The pip command now works.

That’s what solved the problem at this location.

You might want to know as well: The pip commands to install software then needed to be written like this example (jupyter for example) to work correctly on my system:

pip install jupyter –user

Specifically, note the lack of sudo, and the presence of –user

Would be real nice if pip docs had said anything about all this, but that would take typing in more characters I guess.


回答 19

不知道为什么以前没有提到过,但是唯一对我有用的(在我的NVIDIA Xavier上)是:

sudo apt-get install python3-pip

(或sudo apt-get install python-pip对于python 2)

Not sure why this wasnt mentioned before, but the only thing that worked for me (on my NVIDIA Xavier) was:

sudo apt-get install python3-pip

(or sudo apt-get install python-pip for python 2)


回答 20

通过升级python 3解决了这个问题 brew upgrade python:现在我可以这样做:

pip3 install  <package>  

==> python
Python has been installed as
  /usr/local/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have 

Solved this by upgrading python 3 brew upgrade python: Now i can just do:

pip3 install  <package>  

==> python
Python has been installed as
  /usr/local/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have 

回答 21

问题似乎是您的python版本和要安装的库yoıu版本不匹配。例如:如果Django是Django3,而您的python版本是2.7,则可能会收到此错误。

“安装运行后,’python’仍运行Python 2.6,并且PATH未更新。”

1-安装最新版本的Python 2-手动将PATH更改为python38并进行比较。3-尝试重新安装。

我解决了此问题,方法是使用最新版本的Python手动替换PATH。对于Windows:; C:\ python38 \ Scripts

The problem seems that your python version and the library yoıu want to install is not matching versionally. Ex: If Django is Django3 and your python version is 2.7, you may get this error.

“After installing is running ‘python’ still ran Python 2.6 and PATH was not updated.”

1- Install latest version of Python 2- Change your PATH manually as python38 and compare them. 3- Try to reinstall.

I solved this problem as replacing PATH manually with the latest version of Python. As for Windows: ;C:\python38\Scripts


回答 22

我为克服这个问题所做的是sudo apt install python-pip

原来我的虚拟机尚未安装pip。可以想象其他人也可能有这种情况。

What I did to overcome this was sudo apt install python-pip.

It turned out my virtual machine did not have pip installed yet. It’s conceivable that other people could have this scenario too.


回答 23

python-pip在更新pip编辑后使用过时版本的pip(9.0),当前发布的pip版本为(18.0),请/usr/bin/pip替换此导入:

from pip import main

from pip._internal import main

这适用于pip 18.0问题是pip更改main功能名称重复为/usr/bin/pip3/usr/bin/pip2

还认为/usr/local/lib/[your_python_version]/dist-packages/pip/__main__.py它应该与/usr/bin/pip

python-pip use obsolete version of pip (9.0) current post pip version is (18.0) after updating pip edit /usr/bin/pip replace this import:

from pip import main

to

from pip._internal import main

this working for pip 18.0 problem is pip change main function name repeat for /usr/bin/pip3 and /usr/bin/pip2

also view /usr/local/lib/[your_python_version]/dist-packages/pip/__main__.py It should be the same as /usr/bin/pip


回答 24

请执行以下操作:

sudo apt update
sudo apt install python3-pip
source ~/.bashrc

这肯定会安装pip及其所有依赖项。PS这是用于python 3,如果要使用python 2,请从第二个命令中将python3替换为python

sudo apt install python-pip

Do following:

sudo apt update
sudo apt install python3-pip
source ~/.bashrc

This will surely install pip with all its dependencies. PS this is for python 3 if you want for python 2 replace python3 from the second command to python

sudo apt install python-pip

回答 25

要解决Mac中的“ bash:pip:找不到命令 ”问题

在Mac 1上发现两个版本是2.7,另一个是3.7

  • 当我说sudo easy_install pip时,pip在2.7下安装

  • 当我说sudo easy_install-3.7 pip时,pip已安装在3.7下

但是,每当我需要进行pip install时,我都想在python3.7下安装该软件包,因此我在.bash_profile中设置了一个别名(alias pip = pip3)。

所以现在,每当我进行pip install时,都会在python3.7下安装

To overcome the issue “bash: pip: command not found” in Mac

Found two versions on Mac 1 is 2.7 and the other is 3.7

  • when I say sudo easy_install pip, pip got installed under 2.7

  • when I say sudo easy_install-3.7 pip, pip got installed under 3.7

But, whenever I would require to do pip install , I wanted to install the package under python3.7, so I have set an alias (alias pip=pip3)in .bash_profile

so now, whenever I do pip install , it gets installed under python3.7


回答 26

更新的安装命令为pip3

sudo apt-get install python3-pip

The updated command for installing pip3 is :

sudo apt-get install python3-pip