I am encountering a persistent and unresolvable issue with NumPy and Mediapipe installation in Colab, even after taking several troubleshooting steps, including starting with a fresh notebook, factory resetting the runtime, and carefully managing package installation order.
Problem Description:
I am attempting to use Mediapipe (a library for computer vision tasks) along with scikit-learn in a Colab notebook. Mediapipe has a dependency on NumPy (specifically, it requires NumPy version less than 2). However, even when explicitly specifying a compatible NumPy version (e.g., 1.26.4) during installation, Colab seems to be either:
-
Failing to install NumPy at all (and relying on the pre-installed version), or
-
Downgrading the NumPy version, but in a way that is causing a binary incompatibility error for packages that depend on it (such as scikit-learn).
The final result is that even when these packages seem to be downloaded, there is a “cannot import name" error, likely due to inconsistencies between numpy and its underlying packages.
Error Message:
After all those steps, I still obtain this:
Successfully installed hatch-vcs-0.4.0 hatchling-1.27.0 packaging-24.2 pathspec-0.12.1 pluggy-1.5.0 setuptools-76.1.0 trove-classifiers-2025.3.13.13
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
bokeh 3.6.3 requires numpy>=1.16, which is not installed.
cudf-cu12 25.2.1 requires numpy<3.0a0,>=1.23, which is not installed.
tensorboard 2.18.0 requires numpy>=1.12.0, which is not installed.
scikit-image 0.25.2 requires numpy>=1.24, which is not installed.
geopandas 1.0.1 requires numpy>=1.22, which is not installed.
nibabel 5.3.2 requires numpy>=1.22, which is not installed.
matplotlib 3.10.0 requires numpy>=1.23, which is not installed.
shap 0.46.0 requires numpy, which is not installed.
keras 3.8.0 requires numpy, which is not installed.
treelite 4.4.1 requires numpy, which is not installed.
geemap 0.35.3 requires numpy, which is not installed.
missingno 0.5.2 requires numpy, which is not installed.
yellowbrick 1.5 requires numpy>=1.16.0, which is not installed.
spacy 3.8.4 requires numpy>=1.19.0; python_version >= "3.9", which is not installed.
astropy 7.0.1 requires numpy>=1.23.2, which is not installed.
matplotlib-venn 1.1.2 requires numpy, which is not installed.
prophet 1.1.6 requires numpy>=1.15.4, which is not installed.
thinc 8.3.4 requires numpy<3.0.0,>=1.19.0; python_version >= "3.9", which is not installed.
music21 9.3.0 requires numpy, which is not installed.
transformers 4.48.3 requires numpy>=1.17, which is not installed.
cufflinks 0.17.3 requires numpy>=1.9.2, which is not installed.
wordcloud 1.9.4 requires numpy>=1.6.1, which is not installed.
statsmodels 0.14.4 requires numpy<3,>=1.22.3, which is not installed.
holoviews 1.20.2 requires numpy>=1.21, which is not installed.
plotnine 0.14.5 requires numpy>=1.23.5, which is not installed.
spanner-graph-notebook 1.1.3 requires numpy, which is not installed.
dask-cudf-cu12 25.2.2 requires numpy<3.0a0,>=1.23, which is not installed.
arviz 0.20.0 requires numpy>=1.23.0, which is not installed.
pandas-gbq 0.28.0 requires numpy>=1.18.1, which is not installed.
diffusers 0.32.2 requires numpy, which is not installed.
accelerate 1.3.0 requires numpy<3.0.0,>=1.17, which is not installed.
datascience 0.17.6 requires numpy, which is not installed.
pytensor 2.28.3 requires numpy>=1.17.0, which is not installed.
tables 3.10.2 requires numpy>=1.20.0, which is not installed.
pyogrio 0.10.0 requires numpy, which is not installed.
mlxtend 0.23.4 requires numpy>=1.16.2, which is not installed.
dask-cuda 25.2.0 requires numpy<3.0a0,>=1.23, which is not installed.
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-24053960c66c> in <cell line: 13>()
11 import matplotlib.pyplot as plt
12 from google.colab import drive
---> 13 from sklearn.metrics import confusion_matrix, accuracy_score
14 import seaborn as sns
15 from sklearn.model_selection import train_test_split
11 frames
/usr/local/lib/python3.11/dist-packages/numpy/_core/strings.py in <module>
365 raise AssertionError()
366 except AssertionError:
--> 367 msg = ("The current Numpy installation ({!r}) fails to "
368 "pass simple sanity checks. This can be caused for example "
369 "by incorrect BLAS library being linked in, or by mixing "
ModuleNotFoundError: No module named 'numpy.char'
content_copydownload
Use code with caution.
Specific Steps Taken (that have not resolved the issue):
-
Factory reset runtime.
-
Reinstalling packages in the correct order:
!pip install mediapipe
!pip install scikit-learn --upgrade
content_copydownload
Use code with caution.Python
-
Forced reinstallation of scikit-learn.
-
Verbose installations for more detailed output (which showed no explicit errors)
I get as far as “Successful installation of” this and then get a bunch of “Skipping link: No binaries permitted” , then a lot of ModuleNotFoundError: No module named ‘numpy.char’.
Additional Details:
The above approach fails, even for a completely fresh Colab notebook using the CPU. Is there are way I can see a list of all files created in the system? I suspect the old versions might still be there… Also would it help if I tried some code cleaning and removal
I hope your engineers can offer additional tips or insights into this difficult to troubleshoot issue.
Thank you for your help!