当我把MINT升级到22时,发现终端里输入python不出python3了。发现输入pip install xxx,安装不了whl了。我慌的一批,重装了,还是这样。
pip安装软件提示这个了
~$ pip install openpyxl
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.
If you wish to install a non-Debian packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.
See /usr/share/doc/python3.12/README.venv for more information.
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
网上一搜,说改成pipx了。但是用pipx安装软件也不行,提示如下:
~$ pipx install opnepyxl
Fatal error from pip prevented installation. Full pip output in file:
/home/oliveryty/.local/state/pipx/log/cmd_2024-07-28_00.13.34_pip_errors.log
Some possibly relevant errors from pip install:
ERROR: Could not find a version that satisfies the requirement opnepyxl (from versions: none)
ERROR: No matching distribution found for opnepyxl
Error installing opnepyxl.
就是说,pipx不是pip的替代品,pipx不是pip的替代品,pipx不是pip的替代品。
怎么解决这个问题呢,其实前面那个提示结尾说的很清楚了,加上 --break-system-packages。
$ pip install openpyxl --break-system-packages
Defaulting to user installation because normal site-packages is not writeable
WARNING: Skipping /usr/lib/python3.12/dist-packages/argcomplete-3.1.4.dist-info due to invalid metadata entry 'name'
Collecting openpyxl
Downloading openpyxl-3.1.5-py2.py3-none-any.whl.metadata (2.5 kB)
Collecting et-xmlfile (from openpyxl)
Downloading et_xmlfile-1.1.0-py3-none-any.whl.metadata (1.8 kB)
Downloading openpyxl-3.1.5-py2.py3-none-any.whl (250 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 250.9/250.9 kB 510.5 kB/s eta 0:00:00
Downloading et_xmlfile-1.1.0-py3-none-any.whl (4.7 kB)
WARNING: Skipping /usr/lib/python3.12/dist-packages/argcomplete-3.1.4.dist-info due to invalid metadata entry 'name'
Installing collected packages: et-xmlfile, openpyxl
Successfully installed et-xmlfile-1.1.0 openpyxl-3.1.5
也可以在虚拟环境使用pip,但我不习惯。
就这样,散会。