如何使用清华镜像快速安装各种python库
一、准备工作
首先,我们需要准备一个可以访问清华镜像的环境,这样才能使用清华镜像快速安装各种python库。
1. 安装Python:
sudo apt-get install python2. 安装pip:
sudo apt-get install python-pip3. 配置pip镜像源为清华镜像:
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple二、安装Python库
使用清华镜像安装Python库可以加速下载速度,提高安装效率。
1. 普通安装方式:
pip install 库名例如,安装numpy库:
pip install numpy2. 指定版本安装方式:
有时候,我们需要安装特定版本的Python库。可以通过在库名后加上版本号来实现。
例如,安装Pillow库的2.3.0版本:
pip install Pillow==2.3.03. 批量安装方式:
如果我们需要一次性安装多个Python库,可以把库名写入一个文本文件,然后使用-p参数批量安装。
例如,将需要安装的库名写入requirements.txt文件,每行一个库名:
pip install -r requirements.txt三、常用清华镜像源
1. pypi清华源:https://pypi.tuna.tsinghua.edu.cn/simple
2. Anaconda清华源:https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
3. Conda Forge清华源:https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
4. numpy源:https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pkgs/free
5. scipy源:https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/mozilla
6. matplotlib源:https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
以上是使用清华镜像快速安装各种python库的方法。将pip镜像源配置为清华镜像后,可以通过pip命令安装任意需要的Python库,并且可通过指定版本、批量安装等方式满足不同需求。同时,我们还介绍了一些常用的清华镜像源,方便大家选择适合的镜像源。希望以上内容对您有所帮助。
猜您想看
-
Linux命令su、sudo、sudo su、sudo -i使用方法和区别是什么
1.su命令s...
2023年05月22日 -
如何进行Jenkins自动化部署入门
Jenkins...
2023年07月04日 -
怎样理解Rust中的Pin
什么是PinP...
2023年07月21日 -
如何使用Steam页内新闻和视频源跟进游戏发布和更新?
如何使用Ste...
2023年05月12日 -
使用 Typecho 博客的内置插入图片功能,让您的文章更加生动。
Typecho...
2023年04月15日 -
simhash的文本去重原理是什么
一、Simha...
2023年05月26日