Python/pip:修订间差异
来自康健生活
< Python
| (未显示同一用户的1个中间版本) | |||
| 第15行: | 第15行: | ||
{{shc|<syntaxhighlight lang="bash"> | {{shc|<syntaxhighlight lang="bash"> | ||
python setup.py install</syntaxhighlight>|$|/home/kangkk}} | python setup.py install</syntaxhighlight>|$|/home/kangkk}} | ||
==== window ==== | |||
如果是 window 环境,安装 python 之后验证 pip | |||
{{Shc_out|<syntaxhighlight lang="bash"> | |||
python -m pip --version</syntaxhighlight>|<syntaxhighlight lang="bash"> | |||
pip 24.2 from C:\Users\康健\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip (python 3.12) | |||
</syntaxhighlight>|$|/home/kangkk}} | |||
=== 卸载 === | === 卸载 === | ||
| 第64行: | 第72行: | ||
pip install pip-review | pip install pip-review | ||
pip-review --local --interactive</syntaxhighlight>|$|/home/kangkk}} | pip-review --local --interactive</syntaxhighlight>|$|/home/kangkk}} | ||
== error == | |||
* <syntaxhighlight lang="javascript"> | |||
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv | |||
</syntaxhighlight> | |||
2024年9月6日 (五) 16:58的最新版本
安装PIP
安装
easy_inatall 安装
/home/kangkk
easy_inatall pip
编译安装
/home/kangkk
wget https://files.pythonhosted.org/packages/8e/76/66066b7bc71817238924c7e4b448abdb17eb0c92d645769c223f9ace478f/pip-20.0.2.tar.gz
setuptools 安装
pypi 官网下载 setuptools 压缩包
/home/kangkk
wget https://files.pythonhosted.org/packages/b5/96/af1686ea8c1e503f4a81223d4a3410e7587fd52df03083de24161d0df7d4/setuptools-46.1.3.zip
/home/kangkk
python setup.py install
window
如果是 window 环境,安装 python 之后验证 pip
[jian@kang /home/kangkk]$
python -m pip --version
pip 24.2 from C:\Users\康健\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip (python 3.12)
卸载
/home/kangkk
python -m pip uninstall pip
pip-autoremove
/home/kangkk
pip install pip-autoremove
pip-autoremove package-name-here
升级
/home/kangkk
python -m pip install --upgrade pip
# or update pip3
pip3 install --upgrade pip
清理 pip
1. 导出所有包
/home/kangkk
pip freeze > requirements.txt
2. 删除所有包
/home/kangkk
pip uninstall -r requirements.txt
# or
pip uninstall -r requirements.txt -y
参数
--upgrade: 更新。--user: 仅当前安装的用户可用。
other
列出所有安装的库
/home/kangkk
pip list
列出所有过期的库
/home/kangkk
pip list --outdated
批量更新库
update.py
import pip
from subprocess import call
for dist in pip.get_installed_distributions():
call("pip install --upgrade " + dist.project_name, shell=True)
或者使用 pip-review
/home/kangkk
pip install pip-review
pip-review --local --interactive
error
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
No categories