python3-pip 已安装但未找到 pip3 命令?

python3-pip 已安装但未找到 pip3 命令?

我正在几台计算机上测试 Python3 程序。为此,我需要安装一个 Python 库pip3

因此,我首先在每台计算机上进行安装python3-pip(每台计算机都运行 Kubuntu 操作系统)。一切正常,然后我安装了所需的软件包pip3,除了一台计算机外,我成功完成了安装。

在那台计算机上,python3-pip显然安装成功了,但是当我寻找包时,出现了这个错误(翻译是自制的):

Command «pip3» was not found, maybe you wanted to say:
 The command «pip» from the package «python-pip» (universe)
pip3: command not found

编辑

结果dpkg -L python3-pip

/.
/usr
/usr/share
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/pip-3.2.1.gz
/usr/share/doc
/usr/share/doc/python3-pip
/usr/share/doc/python3-pip/changelog.Debian.gz
/usr/share/doc/python3-pip/copyright
/usr/bin
/usr/bin/pip-3.2
/usr/lib
/usr/lib/python3
/usr/lib/python3/dist-packages
/usr/lib/python3/dist-packages/pip
/usr/lib/python3/dist-packages/pip/log.py
/usr/lib/python3/dist-packages/pip/commands
/usr/lib/python3/dist-packages/pip/commands/unzip.py
/usr/lib/python3/dist-packages/pip/commands/zip.py
/usr/lib/python3/dist-packages/pip/commands/install.py
/usr/lib/python3/dist-packages/pip/commands/completion.py
/usr/lib/python3/dist-packages/pip/commands/uninstall.py
/usr/lib/python3/dist-packages/pip/commands/search.py
/usr/lib/python3/dist-packages/pip/commands/freeze.py
/usr/lib/python3/dist-packages/pip/commands/__init__.py
/usr/lib/python3/dist-packages/pip/commands/help.py
/usr/lib/python3/dist-packages/pip/commands/bundle.py
/usr/lib/python3/dist-packages/pip/_pkgutil.py
/usr/lib/python3/dist-packages/pip/util.py
/usr/lib/python3/dist-packages/pip/status_codes.py
/usr/lib/python3/dist-packages/pip/vcs
/usr/lib/python3/dist-packages/pip/vcs/__init__.py
/usr/lib/python3/dist-packages/pip/vcs/mercurial.py
/usr/lib/python3/dist-packages/pip/vcs/git.py
/usr/lib/python3/dist-packages/pip/vcs/bazaar.py
/usr/lib/python3/dist-packages/pip/vcs/subversion.py
/usr/lib/python3/dist-packages/pip/baseparser.py
/usr/lib/python3/dist-packages/pip/exceptions.py
/usr/lib/python3/dist-packages/pip/index.py
/usr/lib/python3/dist-packages/pip/basecommand.py
/usr/lib/python3/dist-packages/pip/req.py
/usr/lib/python3/dist-packages/pip/locations.py
/usr/lib/python3/dist-packages/pip/__init__.py
/usr/lib/python3/dist-packages/pip/runner.py
/usr/lib/python3/dist-packages/pip/backwardcompat.py
/usr/lib/python3/dist-packages/pip/download.py
/usr/lib/python3/dist-packages/pip-1.1.egg-info
/usr/lib/python3/dist-packages/pip-1.1.egg-info/SOURCES.txt
/usr/lib/python3/dist-packages/pip-1.1.egg-info/not-zip-safe
/usr/lib/python3/dist-packages/pip-1.1.egg-info/top_level.txt
/usr/lib/python3/dist-packages/pip-1.1.egg-info/PKG-INFO
/usr/lib/python3/dist-packages/pip-1.1.egg-info/entry_points.txt
/usr/lib/python3/dist-packages/pip-1.1.egg-info/dependency_links.txt

答案1

以下三件事之一可能会解决这个问题:

  1. 万一python3-pip不是安装正确,重新安装:

    这适用于基于 Debian 的发行版,例如 Ubuntu、Mint:

    sudo apt-get remove python3-pip; sudo apt-get install python3-pip
    

    如果使用 Fedora、CentOS、RHEL,请使用:

    sudo dnf reinstall python3-pip
    
  2. 尝试使用命令python3-pip(在 Fedora 上有效;我没有 Kubuntu 的副本可以尝试)。

  3. 只是猜测...检查一下。安装新的pip --version后,有一点可能性python3-pippip代替旧的pip(也许通过alternatives?)

编辑
现在,的输出dpkg -L python3-pip已添加到问题中,我可以提供答案。

正确使用的命令名称是:pip-3.2

答案2

我遇到了这个问题并找到了解决方案。该python3-pip包安装了一个pip-3.2二进制文件。

演出pip-3.2 --version节目:

pip 1.1 from /usr/lib/python3/dist-packages (python 3.2)

python3-pip传达了command not found信息。

我从这里下载了一个“干净”的版本并进行了测试:https://sourceforge.net/projects/rpiqemuwindows/

pip-3.2在安装前检查了一下python3-pip,然后安装后也检查了一下。

答案3

如果你安装了多个 Python 版本,你可能会得到:

bash: pip3: command not found...
Packages providing this file are:
'python36'
'python39-pip'
'python38-pip'

列出已安装的 pips 来说明原因:

$ ls -l /usr/bin | grep pip.*3

pip-3.6 -> ./pip3.6
pip3.6
pip-3.9 -> ./pip3.9
pip3.9

重置 pip3 链接可以解决此问题:

$ sudo ln -s /usr/bin/pip3.9 /usr/bin/pip3
$ pip3

Usage:   
  pip3 <command> [options]

答案4

您可以使用 easy_install:

apt-get install python3-setuptools
easy_install3 pip

相关内容