Python怎么引入不同的库?,1.4.永久修改Li
Python怎么引入不同的库?,1.4.永久修改Li
怎么引入不同的库?
1.在线安装库
1.1.pip install 模块名
1.2.国内源:
清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学:http://pypi.hustunique.com/
山东理工大学:http://pypi.sdutlinux.org/
豆瓣:http://pypi.douban.com/simple/
1.3.临时使用:
可以在使用pip的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple
例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider,这样就会从清华这边的镜像去安装pyspider库。
1.4.永久修改
Linux下,修改 ~/.pip/pip.conf (没有就创建一个文件夹及文件。文件夹要加“.”,表示是隐藏文件夹)内容如下:
[global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install] trusted-host=mirrors.aliyun.com
windows下,直接在user目录中创建一个pip目录,再新建文件pip.ini。(例如:C:\Users\WQP\pip\pip.ini)内容同上。
2.import & from...import
import 模块:导入一个模块;注:相当于导入的是一个文件夹,是个相对路径。 from…import:导入了一个模块中的一个函数;注:相当于导入的是一个文件夹中的文件,是个绝对路径。 所以使用上的的区别是当引用文件时是: import //模块.函数 from…import // 直接使用函数名使用就可以了
原文:
让python pip使用国内镜像
https://www.cnblogs.com/wqpkita/p/7248525.html
相关内容
- 10个优秀的Python库,实用且有趣,本篇文章,小编为大
- flask操作数据库,#在app.py文件
- Python中内置数据库!SQLite使用指南! ⛵,Python内置了
- Python冷知识:如何找出新版本增加或删除了哪些标准库
- 全球名校AI课程库(40)| 威斯康星 · 深度学习和
- 数据库配置限)不用root用户操作数据库了(为数据库创
- 全球名校AI课程库(21)| Harvard哈佛 · Python人工智
- 全球名校AI课程库(23)| Harvard哈佛 · 基于Pytho
- python3使用libpcap库进行抓包及数据处理,这里记录下W
- 全球名校AI课程库(16)| Stanford斯坦福 · 计算机
评论关闭