pip换源
永久换源:
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
临时换源:
pip install numpy -i http://mirrors.aliyun.com/pypi/simple/
pip install -r requirement.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
常用下载源:
阿里云:http://mirrors.aliyun.com/pypi/simple/ 中国科技大学: https://pypi.mirrors.ustc.edu.cn/simple/ 豆瓣: http://pypi.douban.com/simple/ 清华大学: https://pypi.tuna.tsinghua.edu.cn/simple/ 中国科学技术大学: http://pypi.mirrors.ustc.edu.cn/simple/
依赖库管理与本地安装
pip freeze > requirements.txt
pip install -r requirements.txt
pip install xxxxxxx.whl
pip list
pip show -f SomePackage
pip安装权限问题
运行命令 pip install package 时遇到问题:
ERROR: Could not install packages due to an OSError: [WinError 2] 系统找不到指定的文件。: ‘C:\Python310\Scripts\f2py.exe’ -> ‘C:\Python310\Scripts\f2py.exe.deleteme’
解决方案:使用当前用户权限执行 pip 命令
pip install --user package
原因分析:
pip < command > --user 用于更改当前 pip 命令的作用域,使文件安装到当前用户的 python 包安装路径,而不是默认的系统级安装路径(此路径需要管理员权限)。
pip <command> --user changes the scope of the current pip command to work on the current user account’s local python package install location, rather than the system-wide package install location, which is the default. See User Installs in the PIP User Guide. This only really matters on a multi-user machine.
详细原理,请移步 Stackoverflow
pip安装源的可信问题
The repository located at mirrors.aliyun.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS it is recommended to use HTTPS instead, otherwise you may silence this warning and allow it anyways with ‘–trusted-host mirrors.aliyun.com’.
错误提示里已经给出解决方法了,只需要在安装命令加上:
--trusted-host mirrors.aliyun.com
|