1

I am trying to use Google Colab to install MEEP.

!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.8/site-packages/')

I copied the code from here: https://gist.github.com/venky18/e24df1e55502e2d6523881b3f71c0bff.
However, it turns out an error message:

ImportError: /content/anaconda/envs/mp/lib/python3.9/site-packages/meep/_meep.so: undefined symbol: PyCMethod_New

How do I modify my code to install it correctly?

Sam
  • 11
  • 1

1 Answers1

0

From here. This works currently:

!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 -u -p /usr/local 
import os
if os.path.isdir('/content/anaconda'): root_path = '/content/anaconda'
else: root_path = '/usr/local/'
os.environ['PATH'] += f":{root_path}/bin"
!conda create -n mp -c conda-forge pymeep python=3.7 -y
print(">> ", root_path)
import sys
sys.path.append(f'{root_path}envs/mp/lib/python3.7/site-packages/')

I believe the problem with the code snippet you linked was that currently the colab python default version is 3.7.12. Conda now defaults to 3.8. Trying to use packages from a 3.8 install in a 3.7 install is asking for trouble. Adding python=3.7 to the conda create line forces conda to use python 3.7, so the right packages are installed.

IainC
  • 1