Python 基础开发环境搭建

第一步:Python 安装

  • Python 官网下载 Python 安装包

    Python windows 下载地址:64位 install 安装包

  • 选择 Add Python 3.8 to PATH ,然后点击 Customize installation

  • 选择 install for all usersPrecompile standard library 并调整安装位置到固定位置

    image-20210306161144347

  • 验证 Python 是否安装成功

    python --version
    

    image-20210306161618085

第二步:升级 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 文件夹名字的前面有 . 符号。

    image-20210306163929368

  • Linux系统:

添加 ~/.pip以及在该文件夹下 pip.conf 配置文件;

image-20210306164046181

[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脚本

image-20210306164232082

# 查看 site 存放路径
python -m site -help

image-20210306164523216

按照路径找到 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
# 备注:默认即为当前位置
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值