(1)Pycharm在线安装(⭐⭐⭐推荐)
英文版:File-->Settings-->Project:xxx-->Project Interpreter
中文版:文件-->设置-->项目:xxx-->Python解释器
(2)pip在线安装(⭐⭐⭐⭐⭐推荐)
cmd-->pip install 第三方库的名称(例如:pip install requests)
通过上述安装方法有的时候会很慢甚至安装失败/超时(如上图),原因一般是因为这种方式是直接提取国外库里的资源进行安装的。有以下两种方式解决:
①通过VPNFQ安装
②通过国内源安装(pip install 第三方库的名称 -i 国内源地址,例如:pip install requests -i https://mirrors.aliyun.com/pypi/simple/)
常用国内源地址:①阿里云 ②腾讯云 ③清华大学 ④中国科技大学
- 阿里云:https://mirrors.aliyun.com/pypi/simple/
- 腾讯云:https://mirrors.cloud.tencent.com/pypi/simple/
- 清华大学:https://pypi.tuna.tsinghua.edu.cn/simple/
- 中国科技大学:https://mirrors.ustc.edu.cn/pypi/simple/
复制代码
③Python里使用pip命令安装模块时自动添加国内源
使用命令自动生成配置
- # Windows系统
- pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
- # Linux/macOS系统
- pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
复制代码
(3)Python离线安装(⭐推荐) ①下载离线安装包 ②解压 ③把解压后的文件copy到Python的安装路径下 ④打开cmd命令行,进入到Python安装的分区(如:安装在D盘则输入“D:”) ⑤通过cd命令进入到解压后的离线安装包的文件夹 ⑥使用python setup.py install进行安装 |