首页 > 解决方案 > 找不到适用于 python2 命令的平台独立库

问题描述

我正在尝试在 Linux Mint 计算机上安装 pip2,pip3 已经安装在 /.local/lib/python3.6/site-packages 中。我还安装了 Python 2.7 和 Python 3.7:

$ python -V
Python 2.7.15+
$ python3 -V
Python 3.6.9

但是当我尝试安装 pip2 时,它给出了以下错误:

$ python get-pip.py
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site

运行命令 python3 正常打开 python shell,但运行命令 python 给出相同的错误。$PYTHONHOME 或 $PYTHONPATH 均未设置。有人可以向我解释如何解决这个问题吗?

编辑:我没有使用虚拟环境。运行 apt-get check python2 不会显示任何损坏的依赖项。当我将 PYTHONHOME 设置为 /usr 时,python3 命令仍然打开 shell,但是 python 和 python2 命令给出 ImportError: No module named site

标签: pythonpip

解决方案


推荐阅读