AttributeError:'模块'对象没有属性'模板'

时间:2017-03-28 21:59:31

标签: python macos python-2.7 numpy

我在PyCharm环境中使用MacO,我的项目设置为使用Python 2.7.10。现在,我的模块的第一行是:

import numpy as np

当我尝试运行我的代码时,出现以下错误:

/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /{path to file}/numpy_exercise.py
 Traceback (most recent call last): 
File "/{path to file}/numpy_exercise.py", line 1, in module>
 import numpy as np 
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/__init__.py", line 169, in module>
 from . import polynomial 
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/polynomial/__init__.py", line 20, in module>
 from .polynomial import Polynomial 
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/polynomial/polynomial.py", line 68, in module>
 from .polytemplate import polytemplate 
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/polynomial/polytemplate.py", line 17, in module>
 polytemplate = string.Template(''' AttributeError: 'module' object has no attribute 'Template'

(注意"模块>"实际上是双方的括号,但因为它被忽略了,所以我在第一个方括号中找到了它)

虽然在Python 3中它不会发生在我身上。我在网上看了但却找不到任何东西。我不清楚为什么会这样。我很乐意得到你的帮助!

谢谢你们!

0 个答案:

没有答案