mglearn: Can't import and then get a "zsh:1: no matches found:" error
jpanknin opened this issue · 11 comments
- I've installed mglearn in the command line using "pip install mglearn"
- I've also installed it inside the Jupyter notebook using "!pip install mglearn"
But when I import I get a "ModuleNotFoundError: No module named 'mglearn'"
Then I tried to install it inside the Jupyter notebook using the "import sys" and then "!{sys.executable} -m pip install mglearn" method from the site you recommended (https://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/)
When I use the method recommended in the article I get a "zsh:1: no matches found:" error
If I enter "python3" in the terminal, then import mglearn it works fine. I have mglearn.version 0.1.7 and scipy version 1.3.0.
I'm out of ideas and resources on Stackoverflow. Any suggestions on a fix?
Thanks for opening the issue.
Can you say what sys.executable
is? It looks like the python executable that corresponds to the jupyter kernel is not found.
Yes, I think that's the problem too.
which python3
shows .../anaconda/bin/python3
and
print(sys.executable)
shows hands_on_ml/my_env/bin/python3
So it is coming from different places, I just have no idea how to fix. And I have no idea why my Jupyter is coming from inside a virtual environment.
Hm that should be fine though. Maybe the hands_on_ml/my_env/bin/python3
being a relative path is an issue? Are you on linux or OS X?
OS X. Mojave 10.14.6
Maybe the relative path, but I have no issues with any other libraries. I can import sklearn, pandas, numpy, etc. with no problems.
Sorry I was referring to the !{sys.executable}
bit. Certainly your python3
is a different environment from what's running in the notebook. The question was why you can't execute the pip that belongs to that environment.
Are you using conda? In that case you might be able to run conda activate my_env
and then do the pip install mglearn
there.
I've tried opening the notebook directly from the directory and also from inside Anaconda-Navigator. Same problem. I also tried !conda install mglearn
and got the following error:
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- mglearn
Current channels:
- https://repo.anaconda.com/pkgs/main/osx-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/osx-64
- https://repo.anaconda.com/pkgs/r/noarch
To search for alternate channels that may provide the conda package you're
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.
Yes, there is no conda package. Conda packages are sort-of orthogonal to the conda environments.
Can you do conda env list
to list your conda environments?
It looks like you have an environment called my_env
that is used in jupyter. If so, you can run
conda activate my_env
pip install mglearn
and it will fix your issue.
Not sure I did this correctly, but in the terminal I tried conda env list
and got the following:
conda env list [17:50:18]
conda environments:
base * /Users/jpanknin/anaconda3
dsfs /Users/jpanknin/anaconda3/envs/dsfs
Also tried it inside the Jupyter notebook with !conda env list
and got the exact same thing.
The conda activate my_env
gave me the following error:
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run
$ conda init <SHELL_NAME>
Currently supported shells are:
- bash
- fish
- tcsh
- xonsh
- zsh
- powershell
See 'conda init --help' for more information and options.
IMPORTANT: You may need to close and restart your shell after running 'conda init'.
Well looks like you might have multiple installations of anaconda on your machine? You can try following the commands to set up the conda environment correctly but there's no my_env
environment listed in conda env list
so I don't know where the hands_on_ml/my_env/bin/python3
comes from.
It's hard to debug this without knowing how exactly you set up these environments.
Think I got it fixed. You were right. I had 2 different installs of anaconda in different places. I finally had to get a tech from Anaconda on the phone for an hour to troubleshoot, but it's all working now. Appreciate your help, Andreas.
glad you figured it out!