python第三方库的安装pip的使用与换源(解决pip下载速度慢)


python和其他语言一样,也有大量的第三方库
在安装python时默认都会安装pip,安装了pip后
在cmd.exe下可以运行pip

安装库

pip install 库的名字

换源

因为PyPi地址在国外,国内访问速度慢有些地方甚至访问不了,把镜像源换为国内地址速度简直飞起

国内一些常用的软件源如下:
阿里云:https://mirrors.aliyun.com/pypi/simple/
中国科技大学:https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣:https://pypi.douban.com/simple/
清华大学:https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学:https://pypi.mirrors.ustc.edu.cn/simple/

以阿里云镜像源为例

pip install 库的名字 -i https://mirrors.aliyun.com/pypi/simple/

查看已安装的库

pip list

更新库

pip install --upgrade 库名

卸载库

pip uninstall 库的名字

迁移库

pip freeze>requirements.txt-->将本机库列表输出到指定的requirements.txt文件
示例:pip freeze>C:\Users\clefairy\Desktop\requirements.txt-->输出到桌面

pip install-r requirements.txt-->使用pip安装requirements.txt文件中所含的库


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM