【问题标题】:MEEP install in Google Colab在 Google Colab 中安装 MEEP
【发布时间】:2021-08-10 14:52:29
【问题描述】:

我正在尝试使用 Google Colab 安装 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/')

我从这里复制了代码:https://gist.github.com/venky18/e24df1e55502e2d6523881b3f71c0bff
但是,结果显示一条错误消息:

ImportError:/content/anaconda/envs/mp/lib/python3.9/site-packages/meep/_meep.so:未定义符号:PyCMethod_New

如何修改我的代码以正确安装?

【问题讨论】:

    标签: python linux anaconda meep


    【解决方案1】:

    来自here。这目前有效:

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

    我认为您链接的代码 sn-p 的问题是当前 colab python 默认版本是 3.7.12。 Conda 现在默认为 3.8。尝试在 3.7 安装中使用来自 3.8 安装的软件包是自找麻烦。将python=3.7 添加到 conda create 行会强制 conda 使用 python 3.7,因此安装了正确的包。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-02-20
      • 2020-11-18
      • 2021-12-20
      • 2021-07-07
      • 1970-01-01
      • 2018-07-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多