43

我想按照这个说明安装 Tensorflow。 https://www.tensorflow.org/versions/r0.12/get_started/os_setup#pip_installation

但是当我在终端上尝试这段代码时,它会返回一个错误。

$ sudo pip3 install --upgrade $TF_BINARY_URL
sudo: pip3: command not found

所以我安装了 Homebrew 并尝试卸载并重新安装 pip-3,但没有奏效。

MakotonoMacBook-ea:~ makotomiyazaki$ brew uninstall python3-pip
Error: No such keg: /usr/local/Cellar/python3-pip

MakotonoMacBook-ea:~ makotomiyazaki$ brew install python3-pip
Error: No available formula with the name "python3-pip" 
==> Searching for a previously deleted formula...
Warning: homebrew/core is shallow clone. To get complete history run:
  git -C "$(brew --repo homebrew/core)" fetch --unshallow

我应该怎么做才能获得 pip3?我的操作系统是 macOS High Sierra,我已经安装了 python 3.6.2。

编辑:我试过

python3 -m pip

返回的是这个。

The directory '/Users/makotomiyazaki/Library/Caches/pip/http' or its 
parent directory is not owned by the current user and the cache has 
been disabled. Please check the permissions and owner of that 
directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/makotomiyazaki/Library/Caches/pip' or its parent 
directory is not owned by the current user and caching wheels has been 
disabled. check the permissions and owner of that directory. If 
executing pip with sudo, you may want sudo's -H flag.
You must give at least one requirement to install (see "pip help 
install")

我也尝试了 which pip3,但我不知道它是否有效......

MakotonoMacBook-ea:~ makotomiyazaki$ sudo which pip3 install --upgrade $TF_BINARY_URL
/usr/bin/install
4

7 回答 7

115

您需要安装 pip3。

在 Linux 上,命令是:sudo apt install python3-pip

在 Mac 上,首先使用 brew,brew install python3
然后brew postinstall python3

试着打电话pip3 -V看看是否有效。

于 2018-01-25T18:59:26.143 回答
17

我遇到了这个问题,我使用以下步骤修复了它您需要使用以下步骤完全卸载 python3-pip:

sudo apt-get --purge autoremove python3-pip

然后用以下命令重新安装包装:

 sudo apt install python3-pip

要确认一切正常,请运行:

 pip3 -V

在此之后,您现在可以使用 pip3 来管理您感兴趣的任何 python 包。例如

pip3 install NumPy
于 2020-06-10T06:45:15.357 回答
2

编写整个路径/目录,例如。(对于窗户)C:\Programs\Python\Python36-32\Scripts\pip3.exe install mypackage。当我遇到点子问题时,这对我很有效。

于 2017-12-28T22:17:41.140 回答
2

如果您已经安装了 python (pip),则可以通过以下方式在 mac 上进行升级

brew upgrade python
于 2019-01-26T01:39:26.930 回答
1

如果其他方法不起作用,请尝试此操作:

  1. 冲泡安装python3
  2. 酿造链接--覆盖python
  3. 酿造安装后python3
于 2019-07-08T03:38:08.950 回答
1

就我而言,虽然已经安装了 python3-pip,但它无法识别 pip3。重新安装后

sudo yum reinstall python3-pip

它工作正常并且可以识别 pip3 命令。

于 2022-01-07T15:32:12.570 回答
0

之后yum install python3-pip,检查已安装二进制文件的名称。例如

ll /usr/bin/pip*

在我的 CentOS 7 上,它被命名为pip-3而不是pip3.

于 2020-09-18T04:19:52.953 回答