arch linux python venv
0x00 前言
直接使用全局pip安装库的,会有如下error
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try 'pacman -S
python-xyz', where xyz is the package you are trying to
install.
If you wish to install a non-Arch-packaged Python package,
create a virtual environment using 'python -m venv path/to/venv'.
Then use path/to/venv/bin/python and path/to/venv/bin/pip.
If you wish to install a non-Arch packaged Python application,
it may be easiest to use 'pipx install xyz', which will manage a
virtual environment for you. Make sure you have python-pipx
installed via pacman.
最好是创建虚拟环境
create a virtual environment using 'python -m venv path/to/venv'.
我们可以一个项目一个虚拟环境
0x01举例
我们进入项目的根目录后,执行如下命令即可
python -m venv venv
source venv/bin/activate
0x02结果
出现(venv)就成功了
(venv) [lenove@lenove-82er 题目附件]$ pip list
Package Version
---------- -------
pip 23.2.1
setuptools 65.5.0
[notice] A new release of pip is available: 23.2.1 -> 23.3.2
[notice] To update, run: pip install --upgrade pip