gpt4 book ai didi

Mac 上的 Python 3 : ModuleNotFoundError: No module named 'mglearn'

转载 作者:太空宇宙 更新时间:2023-11-03 14:05:33 24 4
gpt4 key购买 nike

我想导入一个在 Python 3 中安装的名为 mglearn 的包。

但不断收到以下错误;

ModuleNotFoundError: No module named 'mglearn'

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

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

我不确定以下是否是确认 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_profile 中注释掉 Python 2.7 的 PATH 后,我尝试了 pip install mglearn ,这样 Python 3.6 的 PATH 才可用。我可以安装 mglearn 并导入 mglearn。也许因为我使用 Anaconda,所以需要 pip 命令来安装该包(这只是我的猜测。)。无论如何,我可以解决这个问题。

关于Mac 上的 Python 3 : ModuleNotFoundError: No module named 'mglearn' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48920478/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com