Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mac上的Python 3:ModuleNotFoundError:没有名为';mglearn';_Python_Python 3.x_Python Import_Importerror - Fatal编程技术网

Mac上的Python 3:ModuleNotFoundError:没有名为';mglearn';

Mac上的Python 3:ModuleNotFoundError:没有名为';mglearn';,python,python-3.x,python-import,importerror,Python,Python 3.x,Python Import,Importerror,我想导入一个名为mglearn的包,它是我在Python3中安装的 但是不断地出现以下错误 ModuleNotFoundError: No module named 'mglearn' 我使用以下命令安装了这个包 (我在同一台MAC上有多个Python环境。) 我不确定以下是否是确认安装在Python3中的mglearn的正确方法,但我看到了这一点 $ python3 -c "help('modules')"|grep mglearn _curses_panel cmath

我想导入一个名为mglearn的包,它是我在Python3中安装的

但是不断地出现以下错误

ModuleNotFoundError: No module named 'mglearn'
我使用以下命令安装了这个包 (我在同一台MAC上有多个Python环境。)

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

$ 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需要做什么吗?

我在~/.bash_配置文件中注释了Python 2.7的路径后,尝试了
pip安装mglearn
,以便Python 3.6的路径仅可用。我可以安装mglearn并导入mglearn。可能是因为我使用了Anaconda,所以安装包时需要使用pip命令(这只是我的猜测)。无论如何,我可以解决这个问题。

也许您可以尝试管理python版本。pyenv允许您在全局、本地(在特定项目中)甚至在当前shell会话中(例如,执行一些测试)设置python版本(3.*或2.*)。下面是如何在Ubuntu和Mac上安装和使用pyenv的简短介绍。

!pip安装mglearn
您是否尝试过此Rajarshi Das。谢谢你的评论。我试过了,似乎这是在Python2.7而不是3.6中安装这个包!pip install mglearn pip install-U mglearn install mglearn要求已是最新的:mglearn in/Library/Frameworks/Python.Frameworks/Versions/2.7/lib/python2.7/site-packages安装找不到满足要求的版本安装(从版本:)没有找到与安装相匹配的发行版
python3-mpip…
是使用3.x安装的正确方法。为什么您认为它没有安装?python3-c“导入mglearn;打印(dir(mglearn))”做什么?(换句话说,你确定导入失败时运行的是python3吗?我想它已经安装好了,因为当我执行python3-c“帮助('modules')”时我可以确认mglearn。grep mglearn。我想我使用的是python3,因为我使用了IPython并看到了这一点。
$IPython Python 3.6.3 | Anaconda,Inc.|(默认,2017年10月6日,12:04:38)
我确实执行了
python3-c“导入mglearn;打印(dir(mglearn))”
并得到了'ModuleNotFoundError:没有名为'scipy'的模块
。因此安装了scipy
python3.6-m pip安装--可信主机pypi.pypi.python.org scipy`但仍然
ModuleNotFoundError:没有名为'mglearn'的模块。
python3-c“导入mglearn;打印(dir)”(scipy))“回溯(最近一次调用):文件“”,第1行,在名称中错误:未定义名称“scipy”。我想我快到了,还有什么建议吗?
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