Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

downgrading numpy version on google colab

I need numpy== 1.18.0 or under 1.20.0, however, I get error as below:

Collecting numpy==1.18
  Using cached numpy-1.18.0.zip (5.4 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> See above for output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  Preparing metadata (pyproject.toml) ... error
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

what I tried are:

  • first I checked the numpy version as below:
import numpy as np
print(np.__version__)

this showed numpy 1.25

  • Then, I uninstalled the current version as bellow:
pip uninstall numpy

it said the numpy was successfully uninstalled.

  • Then, I installed the desired version pip install numpy==1.18 and got the error that I mentioned. I again checked the numpy version and it still shows 1.25, although it showed the numpy has been successfully uninstalled! Also, I tried this process for other under 1.20 numpy versions and the outcome was the same as above!
like image 786
Zahra Avatar asked Dec 23 '25 02:12

Zahra


1 Answers

You can uninstall numpy first:

!pip uninstall numpy -y

Then install the version you need:

!pip install numpy==1.18.0

HOWEVER, as Colab runs on Python version 3.10, even if you can successfully uninstall numpy, it is unlikely you will be able to install numpy 1.18. You may probably like to try: numpy==1.22.1

like image 70
Dawei Wang Avatar answered Dec 25 '25 22:12

Dawei Wang



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!