ImportError: no module named mako.template

蹲街弑〆低调 提交于 2019-12-24 03:06:37

问题


This line of code in my foobar.py file:

from mako.template import *

results in an

ImportError: No module named mako.template

How can I fix this? Both help('modules') and repr(mako) in my Python console assures me that the mako module is installed and available.

I'm on a Mac by the way, running Python 2.6 for this particular project.

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', '/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']


回答1:


Do you have template.py inside your .env/lib/python2.6/site-packages/mako directory?

Are you using virtualenv, or have installed mako in /Library/Python/2.6/site-packages?

Please paste an output of pip freeze


Update:

Have you checked if there is no CR/LF or wrong character on this import line?

What is the encoding of your foobar.py file?

file -I foobar.py

it should contain utf-8 or ascii



来源:https://stackoverflow.com/questions/18066424/importerror-no-module-named-mako-template

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!