如何在 Google Colab 中正确安装 MEEP?

How to properly install MEEP in Google Colab?

过去我在 Google Colab 中安装了 pymeep 包,单元格如下:

!wget -c https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
!chmod +x Miniconda3-latest-Linux-x86_64.sh
!bash ./Miniconda3-latest-Linux-x86_64.sh -b -p ./anaconda
import os
os.environ['PATH'] += ":/content/anaconda/bin"
!conda create -n mp -c conda-forge pymeep
import sys
sys.path.append('/content/anaconda/envs/mp/lib/python3.7/site-packages/') 

这是来自该网站的精确副本:https://rf5.github.io/2019/12/22/meep-intro.html

有时我写的代码不起作用。它执行时没有错误,但是当我尝试执行 import meep as mp 时。我收到以下错误:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-f30f3b609667> in <module>()
----> 1 import meep

ModuleNotFoundError: No module named 'meep'

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------

有没有更好的方法在 Google Colab 中安装 meep 或者 pymeep?

将 3.7 替换为 3.8,因为使用 conda 安装的最新 python 版本是 3.8

sys.path.append('/content/anaconda/envs/mp/lib/python3.8/site-packages/') 

Example