1

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.

  • Are you sure your python install is healthy? Can you install other pip packages? You may also try `pip3` if you have multiple python versions installed in the case that MDAnalysis requires python3 – Mitchell Mar 11 '21 at 00:50
  • Thanks for answer @Mitchell , I didn´t know that `pip3` exists, now I tried `!pip3 install MDAnalysis` and i got the next output: ```Collecting MDAnalysis Downloading https://files.pythonhosted.org/packages/9e/19/1d32ded1891605facf6faf6e0de4ff6bd33db3f7983d84cfc10074363990/MDAnalysis-1.0.1.tar.gz (3.8MB) |████████████████████████████████| 3.8MB 5.4MB/s ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.``` the same error, but i don´t know where check the logs, I've revised Sample data binder but there is nothing. – DJ Boltzmann Mar 11 '21 at 01:11
  • Well this is strange, I tried `!pip2 install MDAnalysis` and start to install, I thought that colab now doesn´t work with Python 2, since january, I olny got one error `ERROR: fastai 0.7.0 has requirement torch<0.4, but you'll have torch 1.4.0 which is incompatible.` but at the final say `Successfully installed GridDataFormats-0.5.0 MDAnalysis-1.0.1 biopython-1.76 gsd-1.7.0 mmtf-python-1.1.2 tqdm-4.59.0` I don´t know how important is torch – DJ Boltzmann Mar 11 '21 at 01:24
  • Now i can´t use `import MDAnalysis` i get the error: `ModuleNotFoundError: No module named 'MDAnalysis'` but it is already installed. – DJ Boltzmann Mar 11 '21 at 01:42
  • Installing MDAnalysis from source requires a working C/C++ compiler and a fair number of dependencies. Although a pip3 install "should" work it depends on having a full development environment installed. Are you able to install with conda? If you look at https://www.mdanalysis.org/pages/installation_quick_start/#conda then you see the basic instructions for a conda installation. Finally, consider asking your questions on the user mailing list https://groups.google.com/group/mdnalysis-discussion – most MDAnalysis developers read it and it's easier to start a dialogue. – orbeckst Mar 11 '21 at 03:58
  • To debug your installation problem it would be _very_ helpful to see the complete output from `pip3 install MDAnalysis` (which is normally many pages of output). Is there a way you can get this output? – orbeckst Mar 11 '21 at 04:01
  • Thank you for your answer @orbeckst, i'm going to review the things that you mention about C/C++ compiler, I was following the install with pip method beacause I'm not using Anaconda, but I figured out that the point you mention is very important, I was checking [tutorial installation](https://www.mdanalysis.org/MDAnalysisTutorial/installation.html) and as far as I know this isn't a characteristic of google colab, so i will have to find a way to run C/C++ in Colab. – DJ Boltzmann Mar 11 '21 at 06:38
  • Thanks for mention the group discussion @orbeckst, of course, i'm going to send a message and confirm if is posible use MDAnalysis on Colab, and understand applications of this library and limitations, I my opinion this is a good alternative if you can't install GROMACS and others, and then i'm going to update this forum. Now I looking for a way to get the complete output of `pip3`. – DJ Boltzmann Mar 11 '21 at 06:45

2 Answers2

1

You can use conda to install MDA in Colab (takes a while).

!wget -O mini.sh https://repo.anaconda.com/miniconda/Miniconda3-4.6.14-Linux-x86_64.sh 
!bash ./mini.sh -b -f -p /usr/local
!conda install -q -y --prefix /usr/local -c conda-forge mdanalysis
import sys
sys.path.append('/usr/local/lib/python3.7/site-packages/')

Then you can import it

import MDAnalysis as mda
korakot
  • 37,818
  • 16
  • 123
  • 144
  • Absolutly awesome! It works, Colab installs conda in 317s fantastic. After that I installed test package with `!conda install -c conda-forge MDAnalysisTests` and I was running some examples, it works perfectly. Thank you @kokarot ! – DJ Boltzmann Mar 15 '21 at 05:10
  • I would like to ask something more, `!conda install -q -y --prefix /usr/local` is a constant line to install every package by this method? you put only the first time and after that you can use conda install methods? – DJ Boltzmann Mar 15 '21 at 05:23
0

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).

orbeckst
  • 3,189
  • 1
  • 17
  • 14
  • Note that Colab runs on Python 3.7 (as of this writing — 3.7.14 (default, Sep 8 2022, 00:06:44) [GCC 7.5.0] ) so you will only be able to install MDAnalysis 2.0 and 2.1. As per [NEP29](https://numpy.org/neps/nep-0029-deprecation_policy.html), [MDAnalysis 2.2 dropped support for Python 3.7](https://www.mdanalysis.org/2022/06/02/release-2.2.0/). (Complain to Google to get in line with the broader Python ecosystem and upgrade the Python version in Colab.) – orbeckst Sep 23 '22 at 17:52