[problem help] pip第三方库无法安装(pip install py7zr)
Tofloor
poster avatar
Iresee
deepin
2024-08-11 18:17
Author

sudo apt install python3-pip
已经安装

root@deepin:/home# pip install py7zr
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.

Reply Favorite View the author
All Replies
米饭虚拟机
deepin
2024-08-11 18:27
#1

试下这个命令:pip3 install py7zr --break-system-packages

Reply View the author
Iresee
deepin
2024-08-11 18:50
#2
米饭虚拟机

试下这个命令:pip3 install py7zr --break-system-packages

可以,但是最好不要用这个命令,会破坏包关系吧

Reply View the author
寂静的羽夏
deepin
2024-08-11 20:12
#3

新版本的限制,首先创建个虚拟环境,然后启用在对应的虚拟环境装包就行了。这个可以从网上搜搜,网上有对应说明。

Reply View the author
兰蔻
deepin
2024-08-11 20:27
#4

按照命令的提示来做就行了,首先安装 pyvenv 的二进制文件,这里以 python3.12 为例:

sudo apt install python3.12-venv

然后创建一个独立的虚拟环境来安装 py7zr :

mkdir -p ~/.pyvenv
python3 -m venv ~/.pyvenv
~/.pyvenv/bin/python -m pip install py7zr

运行:

~/.pyvenv/bin/python -m py7zr

你也可以把 ~/.pyvenv/bin 加入 PATH 环境变量,临时加入可以这样子:

export PATH="$HOME/.pyvenv/bin:$PATH"

永久加入的话,可以在 bash 的启动文件(比如,~/.bashrc)的末尾写入以下代码:

case ":${PATH}:" in
	*:"$HOME/.pyvenv/bin":*)
	;;
	*)  export PATH="$HOME/.pyvenv/bin:$PATH"
	;;
esac
Reply View the author
Lwh2008-Equinox
deepin
2024-08-12 05:34
#5
兰蔻

按照命令的提示来做就行了,首先安装 pyvenv 的二进制文件,这里以 python3.12 为例:

sudo apt install python3.12-venv

然后创建一个独立的虚拟环境来安装 py7zr :

mkdir -p ~/.pyvenv
python3 -m venv ~/.pyvenv
~/.pyvenv/bin/python -m pip install py7zr

运行:

~/.pyvenv/bin/python -m py7zr

你也可以把 ~/.pyvenv/bin 加入 PATH 环境变量,临时加入可以这样子:

export PATH="$HOME/.pyvenv/bin:$PATH"

永久加入的话,可以在 bash 的启动文件(比如,~/.bashrc)的末尾写入以下代码:

case ":${PATH}:" in
	*:"$HOME/.pyvenv/bin":*)
	;;
	*)  export PATH="$HOME/.pyvenv/bin:$PATH"
	;;
esac

like

in most time, most cli application is given us solution...by output..haha

Reply View the author
New Thread

Popular Ranking

Change

Popular Events

More
国际排名
WHLUG