首页 文章

ImportError:没有名为mako.template的模块

提问于
浏览
2

我的foobar.py文件中的这行代码:

from mako.template import *

结果是

ImportError:没有名为mako.template的模块

我怎样才能解决这个问题?我的Python控制台中的 help('modules')repr(mako) 都向我保证mako模块已安装并可用 .

顺便说一下,我在Mac上,为这个特定的项目运行Python 2.6 .

As requested, this is the output from running pip freeze

  • Mako == 0.8.1

  • MarkupSafe == 0.18

  • PyYAML == 3.10

  • wsgiref == 0.1.2

As requested, this is my 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','/ User / username / env / myProject / lib / python2.6 / plan -mac / lib-scriptpackages','/ Users / username / env / myProject / Extras / lib / python','/ Ussers / 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-dadload','/ System / Library / Frame /Python.framework / Version / 2.6 /lib/python2.6','/ System / Library / Frame /Python.framework / Version / 6.6 / lib / python2.6 / plat-Darwin','/ System / Library / Frame /Python.framework / Version / 2.6 /lib/python2.6/lib-tk','/ System / Library / Frame /Python.framework / Version / 6.6 / lib / python2.6 / plat -mac','/ System / Library / Frameworks /Python.framework /Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages','/ User / username / env / myProject / lib / python2.6 / site-package']

1 回答

  • 1

    你的.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

相关问题