0

I have written this code in google collab in python: !pip install -r requirements.txt and getting this output:

Collecting astropy==2.0.3 (from -r requirements.txt (line 1)) Downloading astropy-2.0.3.tar.gz (8.3 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.3/8.3 MB 10.6 MB/s eta 0:00:00 error: subprocess-exited-with-error

× python setup.py egg_info 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 (setup.py) ... 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.

Please help me to install requirments.txt file. I have downloaded this files from github as zipfile and then uploaded to google collab then unzip it.

when I tried to install each manually without version, it worked though some didn't. but it is a hassle to install each manually. i want to install the requirments.txt file directly

  • It would help if you provided the contents of your `requirements.txt` file – Jeff Aug 28 '23 at 20:43
  • astropy==2.0.3 atomicwrites==1.3.0 attrs==19.1.0 boltons==19.1.0 certifi==2019.3.9 contextlib2==0.5.5 cycler==0.10.0 Cython==0.29.10 debtcollector==1.21.0 decorator==4.4.0 dit==1.2.3 importlib-metadata==0.17 joblib==1.2.0 kiwisolver==1.1.0 llvmlite==0.29.0 matplotlib==3.1.0 more-itertools==7.0.0 networkx==2.3 numba==0.44.0 numpy==1.22.0 packaging==19.0 pandas==0.24.2 pbr==5.2.1 pluggy==0.12.0 POT==0.5.1 prettytable==0.7.2 progressbar==2.5 py==1.8.0 pyparsing==2.4.0 pytest==4.6.2 python-dateutil==2.8.0 python-igraph==0.7.1.post6 python-louvain==0.13 – Irin Sultana Aug 30 '23 at 03:48
  • louvain==0.6.1 pytz==2019.1 scikit-learn==0.21.2 scipy==1.3.0 six==1.12.0 sklearn==0.0 umap-learn==0.3.9 wcwidth==0.1.7 wrapt==1.11.1 zipp==0.5.1 – Irin Sultana Aug 30 '23 at 03:49
  • github link: https://github.com/zcang/SpaOTsc/blob/master/requirements.txt – Irin Sultana Aug 30 '23 at 05:52

1 Answers1

0

Ok, after running pip install -v -r requirements.txt (with the -v switch to make the output more versbose) in a default Google Colab instance, it seems the astropy installation fails when looking for the Python library collections.MutableSequence, which apparently got moved to collections.abc.MutableSequence in Python 3.10, which is the Google Colab Python version.

In other words, that version of astropy is incompatible with Python 3.10. You'll need to either find a version that is, or see if you can run a different (compatible) version of Python in your Google Colab instance.

Edit:

As a workaround, try deleting the specific version numbers from your requirements.txt file. In other words, replace the 'astropy==2.0.3' by 'astropy' with no exact version. You could even do this programatically for your entire requirements.txt file using sed as in this answer (to a different question).

Jeff
  • 856
  • 7
  • 13
  • I gave it a go myself and successfully ran `pip install -r requirements.txt` on a versionless `requirements.txt`, but only after also installing a missing C library required by the Cython package using apt-get as follows: `!apt-get install libgmp3-dev` – Jeff Aug 30 '23 at 19:15