首页 > 编程知识 正文

cmd命令安装python第三方库,python cmd安装库

时间:2023-05-06 12:16:21 阅读:267073 作者:4594

如何通过cmd安装Python库

为什么通过cmd安装

本人使用Python的运行软件为Pycharm,其安装和更新库的操作为File>Settings>Project Interpreter>右上角的+图标>输入想要安装的库的名称>Install Package.但这种方法通常会出现安装失败,个人猜测是墙的原因。所以通过cmd进入镜像网站来安装需要的库是一种有效的替代方法。

如何通过cmd安装 我的电脑→右键属性→高级系统设置→环境变量→在系统变量中找到path,双击→点击编辑,添加python所在路径(举个例子,C:UserPython37和C:UserPython37Scripts).根据路径不同做适当修改,但是 Python37和Python37Scripts都要添加,且分为两个变量添加,不是添加在一个变量里。在cmd界面输入python
2.1 若提示’python’ 不是内部或外部命令,也不是可运行的程序或批处理文件。则输入 cd python所在路径Scripts(举个例子,cd C:UserPython37Scripts).输入pip install 库名(举个例子,pip install matplotlib).
3.1 如果出现run timeout的情况(红字满屏幕)则输入pip install --index 镜像网站 库名(举个例子,pip install --index https://pypi.mirrors.ustc.edu.cn/simple matplotlib).所用镜像网站如下,看哪个好用就用哪个 :

Python官方 https://pypi.python.org/simple

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

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

douban http://pypi.douban.com/simple

v2ex http://pypi.v2ex.com/simple

中国科学院 http://pypi.mirrors.opencas.cn/simple/

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

一分快三计划高手镜像网站 库名(举个例子,pip install --index https://pypi.mirrors.ustc.edu.cn/simple matplotlib).所用镜像网站如下,看哪个好用就用哪个 :

Python官方 https://pypi.python.org/simple

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

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

douban http://pypi.douban.com/simple

v2ex http://pypi.v2ex.com/simple

中国科学院 http://pypi.mirrors.opencas.cn/simple/

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

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。