我的简单python代码中出现'module' object has no attribute 'Vector3'
错误。
这是rightAngle.py
档
import meep as mp
import math
cell = mp.Vector3(16, 8, 0)
geometry = [mp.Bloack(mp.Vector3(1e20, 1, 1e20),
center = mp.Vector3(0, 0),
material = mp.Medium(epsilon = 12))]
sources = [mp.Source(mp.ContinuousSource(frequency = 0.15),
component = mp.Ez,
center = mp.Vector3(-7, 0))]
pml_layers = [mp.PML(1.0)]
resolution = 10
使用以下方式进行比赛:
python rightAngle.py >& rightAngle.out
获得此输出:
Traceback (most recent call last):
File "rightAngle.py", line 4, in <module>
cell = mp.Vector3(16, 8, 0)
AttributeError: 'module' object has no attribute 'Vector3'
我正在做的就是从相当可靠的source复制并粘贴给定代码但在Vector3
对象中收到错误。
Python版本:
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
我不知道我错过了什么?
Meep文档: https://meep.readthedocs.io/en/latest/Python_Tutorials/Basics/
答案 0 :(得分:1)
尝试在Ubuntu 16.04上使用时遇到同样的问题。
对我来说有用的是为python 2.7安装Anaconda并使用以下方法创建their recommended environment:
conda create -n mp -c chogan -c defaults -c conda-forge pymeep
之后没有Vector3问题。