Search code examples
pythongitgoogle-colaboratorymdanalysis

Install and Import MDAnalysis on Google Colaboratory for Python? Problems


I'm trying to install and import MDAnalysis and MDAnalysisTests libraries on Google Colaboratory, I've tried three ways but nothing works:

  1. Using default: !pip install library
!pip install MDAnalysis

But I get:

Collecting MDAnalysis
  Using cached https://files.pythonhosted.org/packages/9e/19/1d32ded1891605facf6faf6e0de4ff6bd33db3f7983d84cfc10074363990/MDAnalysis-1.0.1.tar.gz
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

I read that this kind of error is related to a lack of a complementary library or something, but I have no idea where find more information about, so I was hoping that, maybe someone in this forum knows if MDAnalysis requeries something specific. I don´t know what is egg_info, searching I found an example here with the text #egg= in the code, but I talk more about of this option in my last try.

  1. Using default: !apt-get -qq install -y library
!apt-get -qq install -y MDAnalysis

Output:

E: Unable to locate package MDAnalysis

Neither works.

  1. From GitHub

In a preview question I discovery that I can import libraries from GitHub! Awesome! (to be honest I didn´t understand at all the syntaxis), so I looked for the MDAnalysis GitHub respository and I wrote the next code:

!pip install git+https://github.com/MDAnalysis/mdanalysis.git

Output:

Collecting git+https://github.com/MDAnalysis/mdanalysis.git
  Cloning https://github.com/MDAnalysis/mdanalysis.git to /tmp/pip-req-build-4e7svv83
  Running command git clone -q https://github.com/MDAnalysis/mdanalysis.git /tmp/pip-req-build-4e7svv83
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

I found variants with git+git:, git+ssh: but didn't work.

Is this a specific problem of MDAnalysis to work on Colab? or is something wrong in the code? I even tried changing "MDAnalysis" by "mdanalysis". I was following the Colab's guide to install and preview questions on this forum, but I haven´t results. Thanks for read.


Solution

  • Since MDAnalysis 2.0.0, you can directly install MDAnalysis in Colab with pip

    !pip install MDAnalysis
    

    See the example Colab notebook mda_colab_install.ipynb for a demonstration where I install MDAnalysis 2.1.0 together with the tests and the MDAnalysisData package (for example data).