M. Thomas
M. Thomas

Reputation: 61

Python 3 on Mac : ModuleNotFoundError: No module named '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'

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

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

The PATH of my Mac is

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

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

Upvotes: 4

Views: 5256

Answers (2)

Ming
Ming

Reputation: 1

Maybe you can try pyenv to manage the python versions. pyenv allows you to set the python version (3.* or 2.*) globally, locally (in a specific project) or even in the current shell session (do some tests for example). Here is a short post on how to install and use pyenv on Ubuntu and Mac.

Upvotes: 0

M. Thomas
M. Thomas

Reputation: 61

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.

Upvotes: 1

Related Questions