我已遵循说明这里安装 pip3;我需要它来安装其他 python3 包。我不记得很久以前我是否安装过 pip3。运行后sudo apt install python3-pip
,我得到以下输出,
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-pip is already the newest version (8.1.1-2ubuntu0.4).
The following packages were automatically installed and are no longer required:
gyp libavdevice-ffmpeg56 libjs-inherits libjs-node-uuid libuv1-dev
linux-headers-4.13.0-37 linux-headers-4.13.0-37-generic
linux-headers-4.13.0-38 linux-headers-4.13.0-38-generic
linux-headers-4.13.0-39 linux-headers-4.13.0-39-generic
linux-headers-4.13.0-41 linux-headers-4.13.0-41-generic
linux-headers-4.13.0-43 linux-headers-4.13.0-43-generic
linux-headers-4.13.0-45 linux-headers-4.13.0-45-generic
linux-headers-4.15.0-29 linux-headers-4.15.0-29-generic
linux-image-4.13.0-37-generic linux-image-4.13.0-38-generic
linux-image-4.13.0-39-generic linux-image-4.13.0-41-generic
linux-image-4.13.0-43-generic linux-image-4.13.0-45-generic
linux-image-4.15.0-29-generic linux-image-extra-4.13.0-37-generic
linux-image-extra-4.13.0-38-generic linux-image-extra-4.13.0-39-generic
linux-image-extra-4.13.0-41-generic linux-image-extra-4.13.0-43-generic
linux-image-extra-4.13.0-45-generic linux-modules-4.15.0-29-generic
linux-modules-extra-4.15.0-30-generic linux-signed-image-4.13.0-37-generic
linux-signed-image-4.13.0-38-generic linux-signed-image-4.13.0-39-generic
linux-signed-image-4.13.0-41-generic linux-signed-image-4.13.0-43-generic
linux-signed-image-4.13.0-45-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 236 not upgraded.
但是,当我输入 时which pip3
,我没有得到任何输出。再次,当我输入 时pip3 -V
,我得到了以下响应:
The program 'pip3' is currently not installed. You can install it by typing:
sudo apt install python3-pip
我尝试dpkg -L python3-pip
并得到以下输出:
/.
/usr
/usr/lib
/usr/lib/python3
/usr/lib/python3/dist-packages
/usr/lib/python3/dist-packages/pip-8.1.1.egg-info
/usr/lib/python3/dist-packages/pip-8.1.1.egg-info/PKG-INFO
/usr/lib/python3/dist-packages/pip-8.1.1.egg-info/dependency_links.txt
/usr/lib/python3/dist-packages/pip-8.1.1.egg-info/not-zip-safe
/usr/lib/python3/dist-packages/pip-8.1.1.egg-info/requires.txt
/usr/lib/python3/dist-packages/pip-8.1.1.egg-info/entry_points.txt
/usr/lib/python3/dist-packages/pip-8.1.1.egg-info/top_level.txt
/usr/lib/python3/dist-packages/pip
/usr/lib/python3/dist-packages/pip/baseparser.py
/usr/lib/python3/dist-packages/pip/__main__.py
/usr/lib/python3/dist-packages/pip/req
/usr/lib/python3/dist-packages/pip/req/req_set.py
/usr/lib/python3/dist-packages/pip/req/req_install.py
/usr/lib/python3/dist-packages/pip/req/__init__.py
/usr/lib/python3/dist-packages/pip/req/req_file.py
/usr/lib/python3/dist-packages/pip/req/req_uninstall.py
/usr/lib/python3/dist-packages/pip/index.py
/usr/lib/python3/dist-packages/pip/status_codes.py
/usr/lib/python3/dist-packages/pip/utils
/usr/lib/python3/dist-packages/pip/utils/setuptools_build.py
/usr/lib/python3/dist-packages/pip/utils/appdirs.py
/usr/lib/python3/dist-packages/pip/utils/outdated.py
/usr/lib/python3/dist-packages/pip/utils/ui.py
/usr/lib/python3/dist-packages/pip/utils/logging.py
/usr/lib/python3/dist-packages/pip/utils/encoding.py
/usr/lib/python3/dist-packages/pip/utils/deprecation.py
/usr/lib/python3/dist-packages/pip/utils/__init__.py
/usr/lib/python3/dist-packages/pip/utils/filesystem.py
/usr/lib/python3/dist-packages/pip/utils/hashes.py
/usr/lib/python3/dist-packages/pip/utils/build.py
/usr/lib/python3/dist-packages/pip/compat
/usr/lib/python3/dist-packages/pip/compat/dictconfig.py
/usr/lib/python3/dist-packages/pip/compat/__init__.py
/usr/lib/python3/dist-packages/pip/compat/ordereddict.py
/usr/lib/python3/dist-packages/pip/models
/usr/lib/python3/dist-packages/pip/models/index.py
/usr/lib/python3/dist-packages/pip/models/__init__.py
/usr/lib/python3/dist-packages/pip/vcs
/usr/lib/python3/dist-packages/pip/vcs/bazaar.py
/usr/lib/python3/dist-packages/pip/vcs/subversion.py
/usr/lib/python3/dist-packages/pip/vcs/mercurial.py
/usr/lib/python3/dist-packages/pip/vcs/__init__.py
/usr/lib/python3/dist-packages/pip/vcs/git.py
/usr/lib/python3/dist-packages/pip/cmdoptions.py
/usr/lib/python3/dist-packages/pip/basecommand.py
/usr/lib/python3/dist-packages/pip/commands
/usr/lib/python3/dist-packages/pip/commands/completion.py
/usr/lib/python3/dist-packages/pip/commands/install.py
/usr/lib/python3/dist-packages/pip/commands/hash.py
/usr/lib/python3/dist-packages/pip/commands/uninstall.py
/usr/lib/python3/dist-packages/pip/commands/__init__.py
/usr/lib/python3/dist-packages/pip/commands/list.py
/usr/lib/python3/dist-packages/pip/commands/search.py
/usr/lib/python3/dist-packages/pip/commands/show.py
/usr/lib/python3/dist-packages/pip/commands/download.py
/usr/lib/python3/dist-packages/pip/commands/wheel.py
/usr/lib/python3/dist-packages/pip/commands/freeze.py
/usr/lib/python3/dist-packages/pip/commands/help.py
/usr/lib/python3/dist-packages/pip/_vendor
/usr/lib/python3/dist-packages/pip/_vendor/__init__.py
/usr/lib/python3/dist-packages/pip/operations
/usr/lib/python3/dist-packages/pip/operations/__init__.py
/usr/lib/python3/dist-packages/pip/operations/freeze.py
/usr/lib/python3/dist-packages/pip/__init__.py
/usr/lib/python3/dist-packages/pip/locations.py
/usr/lib/python3/dist-packages/pip/pep425tags.py
/usr/lib/python3/dist-packages/pip/exceptions.py
/usr/lib/python3/dist-packages/pip/download.py
/usr/lib/python3/dist-packages/pip/wheel.py
/usr/share
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/pip3.1.gz
/usr/share/doc
/usr/share/doc/python3-pip
/usr/share/doc/python3-pip/copyright
/usr/bin
/usr/bin/pip3
/usr/share/doc/python3-pip/changelog.Debian.gz
这意味着pip3已经安装。
我该如何解决这个问题?
更多细节:我在 /usr/local/lib/ 中安装了 python 2.7 和 python 3。python 2.7 具有以下 pip 安装:
/usr/local/lib/python2.7/dist-packages/pip
/usr/local/lib/python2.7/dist-packages/pip-10.0.0.dist-info
/usr/local/lib/python2.7/dist-packages/pip-18.0.dist-info
而 /usr/local/lib/python3.5/ 中没有 pip3 安装。python3 中只有 pip 安装。
我该如何解决这个问题?
答案1
尝试python3 -m pip3 install pip
。
您可能正在尝试使用 Python2 来运行 pip3,这就是您看到错误的原因。