Mac上的Python 3:ModuleNotFoundError:没有名为"mglearn"的模块 [英] Python 3 on Mac : ModuleNotFoundError: No module named 'mglearn'

查看:95
本文介绍了Mac上的Python 3:ModuleNotFoundError:没有名为"mglearn"的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想导入我在Python 3中安装的名为mglearn的软件包.

I want to import a package called mglearn that I installed in Python 3.

但是继续出现以下错误;

But keep getting the following error;

ModuleNotFoundError: No module named 'mglearn'

我使用以下命令安装了此软件包(我在同一MAC上有多个Python环境.)

I installed this package using the following command (I have multiple Python environments on the same MAC.)

$ python3.6 -m pip install --trusted-host pypi.python.org mglearn

我不确定以下方法是否是确认安装在Python3中的mglearn的正确方法,但是看到了这一点;

I'm not sure if the following is the right way to confirm mglearn installed in Python3 but saw this;

$ python3 -c "help('modules')"|grep mglearn
_curses_panel       cmath               mglearn             stringprep

我的Mac的路径是

PATH=/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/firstname.surname/.pyenv/versions/anaconda3-2.5.0/bin/:/Users/firstname.surname/.pyenv/shims:/Users/firstname.surname/.pyenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/Applications/Wireshark.app/Contents/MacOS

有人可以告诉我导入mglearn时需要做什么吗?

Can anyone tell me what I need to do to import mglearn?

推荐答案

在将〜/.bash_profile中的Python 2.7注释掉之后,我尝试了 pip install mglearn ,因此仅Python 3.6的PATH可用的.我可以安装mglearn并导入mglearn.也许是因为我使用Anaconda,所以需要pip命令来安装该软件包(这只是我的猜测.).无论如何,我可以解决问题.

I tried pip install mglearn, after commenting out PATH for Python 2.7 in ~/.bash_profile so that PATH for Python 3.6 is only available. I could install mglearn and import mglearn. Maybe because I use Anaconda, pip command was necessary to install the package (This is just my guess.). Anyway, I could solve the problem.

这篇关于Mac上的Python 3:ModuleNotFoundError:没有名为"mglearn"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆