在 Google Colaboratory 上为 Python 安装并导入 MDAnalysis?问题

Install and Import MDAnalysis on Google Colaboratory for Python? Problems

我正在尝试在 Google Colaboratory 上安装和导入 MDAnalysis 和 MDAnalysisTests 库,我尝试了三种方法但没有任何效果:

  1. 使用默认:!pip 安装库
!pip install MDAnalysis

但我得到:

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.

我读到这种错误与缺少补充库或其他东西有关,但我不知道在哪里可以找到更多相关信息,所以我希望,也许这个论坛中有人知道 MDAnalysis 是否重新查询具体的东西。我不知道什么是 egg_info,我在搜索中找到了一个示例 ,文本为 #egg=代码,但我在上次尝试中更多地讨论了这个选项。

  1. 使用默认值:!apt-get -qq install -y library
!apt-get -qq install -y MDAnalysis

输出:

E: Unable to locate package MDAnalysis

都不行。

  1. 来自GitHub

在预览中 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 我写了下一个代码:

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

输出:

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.

我找到了带有 git+git:, git+ssh: 的变体,但没有用。

这是在 Colab 上工作的 MDAnalysis 的特定问题吗?还是代码有问题?我什至尝试通过“mdanalysis”更改“MDAnalysis”。我在这个论坛上关注 Colab's guide 安装和预览问题,但我没有结果。感谢阅读。

您可以使用 conda 在 Colab 中安装 MDA(需要一段时间)。

!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/')

然后就可以导入了

import MDAnalysis as mda

从 MDAnalysis 2.0.0 开始,您可以直接在 Colab 中安装 MDAnalysis pip

!pip install MDAnalysis

查看示例 Colab 笔记本 mda_colab_install.ipynb for a demonstration where I install MDAnalysis 2.1.0 together with the tests and the MDAnalysisData 包(例如数据)。