Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install umap and umap.plot with Google Colab

I apologize ahead of time for this question, but I am stuck in a loop between GitHub issue discussions and !pip install ... attempts.

The problem is that I can't import into Python within Google Colab the package umap, and more specifically, umap.plot At first it gave me a warning that I needed to install holoviews, datashader and bokeh before installing umap, and I did make sure that all required packages were installed. Since it was still unable to run the cell with all the import commands, I changed the order of the packages, leaving umap for the end, which did not help. In fact, all of a sudden it was holoviews that seemed to be the problem, despite the fact that I seemed to have installed it successfully. See the error I got (right side):

enter image description here

And this is the snippet of code:

%autosave 0

import warnings; warnings.simplefilter('ignore')

import matplotlib.pyplot as plt

import pandas as pd
import numpy as np
import seaborn as sns

from mpl_toolkits.mplot3d import Axes3D
from matplotlib.ticker import NullFormatter

from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn import manifold
from sklearn.utils import check_random_state

import holoviews
import datashader
import bokeh
from bokeh.plotting import show, save, output_notebook, output_file
from bokeh.resources import INLINE 

import umap
import umap.plot

plt.rcParams["figure.figsize"] = (20,10)

And this is the original error message before changing the order of the packages:

enter image description here

like image 889
Antoni Parellada Avatar asked Sep 03 '25 04:09

Antoni Parellada


1 Answers

I just ran

!pip install umap-learn[plot]
!pip install holoviews
!pip install -U ipykernel

and all clear!

Got this from here.

like image 174
Antoni Parellada Avatar answered Sep 04 '25 17:09

Antoni Parellada



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!