ModuleNotFoundError installing yellowbrick in Python
Asked Answered
W

4

9

I am having trouble installing yellowbrick.

I am using Anaconda, hence I took advantage of using the "conda install".

# set number of clusters
kclusters = 5

pittsburgh_grouped_clustering = pittsburgh_grouped.drop('Neighborhood', 1)

X = pittsburgh_grouped.drop('Neighborhood', 1)

from sklearn.cluster import KMeans
!conda install -c districtdatalabs yellowbrick
from yellowbrick.cluster import KElbowVisualizer

# instantiate the model and visualizer
model = KMeans()
visualizer = KElbowVisualizer(model, k=(1,10))

visualizer.fit(X) # fit data to visualizer
visualizer.poof() # draw/show/poof the data

I expect the package to be installed. The error message I am receiving is:

ModuleNotFoundError: No module named 'yellowbrick'.

What am I missing?

Wreak answered 8/7, 2019 at 20:49 Comment(1)
Have you tried installing it. See anaconda.org/DistrictDataLabs/yellowbrickEyelash
T
9

First install yellowbrick outside of your code and verify that it actually installed. You can do this through the terminal doing exactly what you say. You may need to upgrade/downgrade your libraries which may not be happening when you install in your script.

Then try and run your script without the !conda install -c districtdatalabs yellowbrick because once its installed you don't have to install it again.

Ticktacktoe answered 8/7, 2019 at 20:58 Comment(5)
For some reason the "!conda install" was not working even though I was using a Jupyter notebook in Anaconda. I used "!pip install yellowbrick", and it was successfully installed/imported. Thank you for your response! :)Wreak
@MoKaiser, while sometimes that will help in troubleshooting, it is generally bad to switch to pip if Anaconda/conda is your primary package by choice, because you chose to install it and use that. The issue you encountered as been solved though. I'll cover it in a new comment because it is important now because this accepted answer is outdated AND SHOULD BE UPDATED.Serotherapy
This solution is now suggesting an approach that is outdated and can lead to issues as Mo Kaiser encountered. In 2019 the magic version of %conda install was added to ensure the installation occurs in the environment where the kernel backing the active notebook is running. The exclamation point combination doesn't do that and likely was the issue Mo encountered when trying the current version of this solution. Specifically the magic command %conda install districtdatalabs::yellowbrick or %conda install conda-forge::yellowbrick should be the accepted answer. ...Serotherapy
<continued> Those two commands are based on here and here, respectively, combined with the magic install command for running inside modern Jupyter cells. See more about the modern %conda install command here. The second paragraph here ...Serotherapy
<continued> goes into more details about why the exclamation point may lead to issues.Serotherapy
L
4

Steps to follow:

  1. Open Anaconda Navigator
  2. Environments
  3. Open Terminal
  4. Copy-paste "pip install yellowbrick"
Ligroin answered 31/12, 2020 at 13:18 Comment(0)
G
0

My experienced the same thing but I tried and it worked by using the following steps :

  1. Open search on your windows
  2. Look for anaconda prompt, and click
  3. conda install -c districtdatalabs yellowbrick (use the following script to install the yellowbrick module) enter image description here

Where do I get the script from? Here I attach the link: https://anaconda.org/DistrictDataLabs/yellowbrick

Gogol answered 23/8, 2022 at 13:29 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Sororicide
D
0

If:

conda install -c districtdatalabs yellowbrick

failed, you can do the following:

  1. from Anaconda Navigator environments menu select all from the dropdown list.
  2. search for Yellowbrick package.
  3. install the package.

See the Anaconda Finding and installing packages page for more details.

Dromous answered 11/7 at 2:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.