在 Google Colaboratory for Python 上安装和导入 MDAnalysis?问题

问题描述

我正在尝试在 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= 的示例 here,但我更多地谈论了这个我最后一次尝试的选项。

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

输出

E: Unable to locate package MDAnalysis

两者都不起作用。

  1. 来自 GitHub

在预览 question 中,我发现我可以从 GitHub 导入库!惊人的! (老实说,我完全不理解语法),所以我寻找 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: 的变体,但没有用。

这是 MDAnalysis 用于 Colab 的特定问题吗?还是代码有问题?我什至尝试通过“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