ImportError:没有名为mako.template的模块
这行代码在我的foobar.py文件中:
from mako.template import *
导致一个
ImportError:没有名为mako.template的模块
我怎样才能解决这个问题? 这两个help('modules')
和repr(mako)
在我的Python控制台中向我保证,mako模块已安装并可用。
顺便说一句,我在Mac上运行Python 2.6,用于这个特定的项目。
根据要求,这是运行pip冻结的输出
按要求,这是我的sys.path
['','/Users/username/env/myProject/lib/python26.zip','/Users/username/env/myProject/lib/python2.6','/ Users / username / env / myProject / lib / python2.6 / plat-darwin','/Users/username/env/myProject/lib/python2.6/plat-mac','/Users/username/env/myProject/lib/python2.6/plat-mac/ lib / scriptpackages','/ Users / username / env / myProject / Extras / lib / python','/Users/username/env/myProject/lib/python2.6/lib-tk','/ Users / username / env /myProject/lib/python2.6/lib-old','/Users/username/env/myProject/lib/python2.6/lib-dynload','/System/Library/Frameworks/Python.framework/Versions/2.6 /lib/python2.6','/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin','/System/Library/Frameworks/Python.framework/Versions/2.6 /lib/python2.6/lib-tk','/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac','/System/Library/Frameworks/Python.framework /Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages','/Users/username/env/myProject/lib/python2.6/site-packages']
你的.env / lib / python2.6 / site-packages / mako目录中有template.py吗?
你使用virtualenv还是在/Library/Python/2.6/site-packages中安装了mako?
请粘贴pip freeze
的输出
更新:
您是否检查过此导入线上是否没有CR / LF或错误的字符?
foobar.py文件的编码是什么?
file -I foobar.py
它应该包含utf-8或ascii
链接地址: http://www.djcxy.com/p/55269.html上一篇: ImportError: no module named mako.template
下一篇: import pymongo works in Python interpreter but not script