吴恩达机器学习笔记——踩了最多坑的Pycharm 导入numpy,pandas和matplotlib

在用python学习吴恩达的机器学习中(https://www.kesci.com/home/column/5dd7524c83b6ff002c786fff),ex1需要导入numpy,pandas,matplotlib三个库。踩了不少坑,在此记录

1. Microsoft Visual C++ 报错

提示"error: Microsoft Visual C++ 14.0 is required. Get it with “Build Tools for Visual Studio”:https://visualstudio.microsoft.com/downloads/ Tools":"

解决:建议直接安装Microsoft Visual C++ Build Tools
详见文章:https://zhuanlan.zhihu.com/p/126669852

2.在Project Setting中导入numpy,pandas和matplotlb
我的python是3.8的版本,开始numpy安装会报

安装包出现Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError”

想了想估计又是网速的问题(java的maven在拉取依赖的时候也遇到过这个问题),搜了一下镜像(记得看清http和https!!

阿里云 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/

如果是cmd直接安装,以豆瓣安装numpy为例子

pip install web.py -i

如果用Pycharm安装

  • 选择setting

在这里插入图片描述

  • 进入Project Interpreter,点击加号
    在这里插入图片描述

  • 先添加镜像,点击manage repository,然后添加镜像网址(我这里加了3个)
    在这里插入图片描述

  • ok确认以后搜索numpy,选中,Install package。
    在这里插入图片描述

  • 如果报错镜像来源不被信任,选中options选项,加–trusted-host
    pypi.douban.com(host后是根据自己选择的镜像替换的)

-在这里插入图片描述
3. matplotlib导入
我本来以为就可以顺利进行了!但是!!!matplotlib无论用什么镜像都无法导入!!pip也升级到最新版本了!(朋友们可以去确认一下是不是自己的pip版本旧了,cmd输入

pip install --upgrade pip -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

然后搜到是matplotlib不支持3.8版本的python……(手动狗头
我就下载了一个3.7的版本,丢个网盘链接

链接:https://pan.baidu.com/s/1Cmd4zlkPemtv_-ntg6eQSQ 提取码:j831

下载安装以后(我的Python文件下现在就有Python37和Python38两个文件啦),把编译器定位到python37的python.exe,就可以导入matplotlib了!(这里不熟悉的朋友可以搜一下ptyhon编译器看看怎么切换
在这里插入图片描述在这里插入图片描述

就是这样了!有帮到你的话给个赞吧!笔芯~

更多推荐