简体   繁体   English

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

[英]How to properly install MEEP in Google Colab?

In the past I have installed the pymeep package in Google Colab with the following cell:过去,我在 Google Colab 中安装了 pymeep package,其中包含以下单元:

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

Which is an exact copy from this website: https://rf5.github.io/2019/12/22/meep-intro.html这是该网站的精确副本: https://rf5.github.io/2019/12/22/meep-intro.ZFC35FDC70D5FC69D269883A822C7A5

Sometimes the code I wrote doesn't work.有时我写的代码不起作用。 It executes without errors, but when I try to execute import meep as mp .它执行没有错误,但是当我尝试执行import meep as mp时。 I get the following error:我收到以下错误:

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

Is there a better way of installing meep or rather pymeep in Google Colab?有没有更好的方法在 Google Colab 中安装 meep 或 pymeep?

Replace 3.7 with 3.8 as the latest python version installed using conda is 3.8将 3.7 替换为 3.8,因为使用 conda 安装的最新 python 版本是 3.8

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

Example

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM