我想导入一个在 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 命令来安装该包(这只是我的猜测。)。无论如何,我可以解决这个问题。
我是一名优秀的程序员,十分优秀!