05--pip install 安装python包国内镜像源

加速安装opencv-python:使用国内镜像源
这篇博客介绍了如何使用国内的pip镜像源来加速安装opencv-python包。提供的镜像源包括阿里云、中国科技大学、豆瓣、清华大学和中国科学技术大学。通过在pip安装命令中添加-i参数和镜像源地址,可以显著提高下载速度。

1、安装opencv关于python包
这句是安装opencv的包指令
pip install opencv-python
但是,下载速度太慢了,可以使用国内的镜像源

pip install opencv-python -i https://pypi.tuna.tsinghua.edu.cn/simple/

使用清华源镜像下载
-i 后面为镜像源的地址

国内的pip源,如下:

阿里云 http://mirrors.aliyun.com/pypi/simple/

中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

豆瓣(douban) http://pypi.douban.com/simple/

清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/

中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

在使用 `apt install python-pip` 安装 `pip` 时,本质上是通过 `apt` 管理器进行安装,这里涉及到 `apt` 的镜像配置,而非 `pip` 镜像配置。以下介绍在 Debian 和 Ubuntu 系统中配置 `apt` 镜像源的方法。 ### 备份原有的源列表文件 在修改 `apt` 源列表之前,建议先备份原有的源列表文件 `/etc/apt/sources.list`: ```bash sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak ``` ### 编辑源列表文件 使用文本编辑器(如 `vim` 或 `nano`)打开 `/etc/apt/sources.list` 文件: ```bash sudo vim /etc/apt/sources.list ``` 在文件中添加或替换为国内镜像源,以阿里云镜像源为例: ```plaintext deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse ``` 其中 `focal` 是 Ubuntu 20.04 的代号,根据自己的系统版本进行替换。 ### 更新软件索引 修改完源列表后,执行以下命令更新软件索引: ```bash sudo apt update ``` ### 安装 `python-pip` 更新索引后,就可以使用以下命令安装 `python-pip`: ```bash sudo apt install python-pip ``` ### 配置 `pip` 镜像源 安装完成 `pip` 后,如果需要配置 `pip` 镜像源,可以创建或编辑 `~/.pip/pip.conf` 文件: ```bash mkdir -p ~/.pip vim ~/.pip/pip.conf ``` 在文件中添加以下内容,以阿里云 `pip` 镜像源为例: ```plaintext [global] index-url = https://mirrors.aliyun.com/pypi/simple/ [install] trusted-host = mirrors.aliyun.com ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值