第一步:Python 安装
-
从
Python
官网下载Python
安装包Python windows
下载地址:64位install
安装包 -
选择
Add Python 3.8 to PATH
,然后点击Customize installation
-
选择
install for all users
和Precompile standard library
并调整安装位置到固定位置 -
验证
Python
是否安装成功python --version
第二步:升级 pip 到最新版本
python -m pip install --upgrade pip
第三步:pip
跟换国内镜像
# Windows 系统使用的镜像: 阿里云 https://mirrors.aliyun.com/pypi/simple/ 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/ 豆瓣(douban) https://pypi.douban.com/simple/ 清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/ 中国科学技术大学 https://pypi.mirrors.ustc.edu.cn/simple/ # 注意:ubuntu 系统需要使用 https 源 清华:https://pypi.tuna.tsinghua.edu.cn/simple 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
两种使用方式:
一、每次安装使用参数 -i 指定镜像地址
pip install -i https://mirrors.aliyun.com/pypi/simple/ matplotlib
二、编辑配置文件,设定全局安装镜像地址
-
Windows系统:
添加 C:\Users\user_name\ .pip 文件以及在该文件夹下添加 pip.conf 配置文件,也可以添加 C:\Users\user_name\pip 文件夹以及添加 pip.ini 配置文件;pip.conf 与 pip.ini 的功能相同,需要注意 .pip 文件夹名字的前面有 . 符号。
-
Linux系统:
添加 ~/.pip以及在该文件夹下 pip.conf 配置文件;
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
第四步:更换本地 pip install
下载路径
# 查看当前 python 安装目录
python -m site
# USER_SITE: 自定义Python依赖安装包的基础路径。
# USER_BASE: 自定义Python脚本
# 查看 site 存放路径
python -m site -help
按照路径找到 site.py 文件,并修改其中内容
USER_SITE = None
USER_BASE = None
# 修改为:
USER_SITE = D:\Program Files\Python\Python39\Lib\site-packages
USER_BASE = D:\Program Files\Python\Python39\Scripts
# 备注:默认即为当前位置