sorl.thumbnail : “缩略图”不是有效的标签库?
我正在尝试安装 sorl.thumbnail,但收到以下错误消息:
'thumbnail' 不是有效的标记库:无法从 django.templatetags.thumbnail 加载模板库,没有名为 PIL 的模块
此问题中弹出此错误为嗯
需要帮助解决 sorl-thumbnail错误:“‘缩略图’不是有效的标签库:”
但提供的解决方案对我来说没有好处。解决方案是将项目文件夹附加到 sorl 文件中的所有导入中。出于显而易见的原因,我希望将我的应用程序与它们所在的项目分开。
我已将 sorl 文件夹放入我的项目文件夹中
我已将“sorl.thumbnaills”放置在已安装的应用程序下
最后将 {% loadthumbnail %} 放入 base.html
$python2.5
>>>import PIL
>>>import sorl
这些工作。
使用 python2.5,在 ubuntu 9.04 上使用 django 1.1 和 appengine-patch
要尝试其他一些东西,我放在了 settings.py 文件中:
import sys
sys.path.append("/home/danielle/bu3/mysite/sorl/thumbnail")
但这也不起作用。 一些更多的帮助将不胜感激......我应该如何改变我的道路?
当前路径(没有上述导入): ['/home/danielle/bu3/mysite', '/home/danielle/bu3/mysite/common', '/home/danielle/bu3/mysite/common/appenginepatch/appenginepatcher/lib', '/home/danielle/ bu3/mysite/common/zip-packages/django-1.1.zip'、'/home/danielle/bu3/mysite/common/appenginepatch'、'/usr/local/google_appengine'、'/usr/local/google_appengine/lib /antlr3'、'/usr/local/google_appengine/lib/yaml/lib'、'/usr/local/google_appengine/lib/django'、'/usr/local/google_appengine/lib/webob'、'/home/danielle /bu3/mysite','/usr/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg','/usr/lib/python2.5/site-packages/ZopeSkel-2.10- py2.5.egg','/usr/lib/python2.5/site-packages/virtualenv-1.3.2-py2.5.egg','/usr/lib/python2.5/site-packages/pip- 0.3.1-py2.5.egg','/usr/lib/python2.5/site-packages/virtualenvwrapper-1.12-py2.5.egg','/usr/lib/python2.5/site-packages/ PyYAML-3.08-py2.5-linux-i686.egg','/usr/lib/python2.5/site-packages/xlutils-1.3.0-py2.5.egg','/usr/lib/python2. 5/site-packages/errorhandler-1.0.0-py2.5.egg', '/usr/lib/python2.5/site-packages/xlwt-0.7.1-py2.5.egg', '/usr/ lib/python2.5/site-packages/xlrd-0.7.0-py2.5.egg', '/usr/lib/python2.5/site-packages/Fabric-0.0.9-py2.5.egg', '/usr/lib/python2.5/site-packages/multitask-0.2.0-py2.5.egg', '/usr/lib/python2.5/site-packages/logilab.pylintinstaller-0.15.2-py2 .5.egg','/usr/lib/python2.5/site-packages/pylint-0.15.2-py2.5.egg','/usr/lib/python2.5/site-packages/clonedigger-1.0 .9_beta-py2.5.egg', '/usr/lib/python2.5/site-packages/yolk-0.4.1-py2.5.egg', '/usr/lib/python2.5/site-packages /MySQL_python-1.2.3c1-py2.5-linux-i686.egg', '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2', '/usr/lib/ python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site-packages', '/usr/lib/python2.5 /site-packages'、'/usr/lib/python2.5/site-packages/Numeric'、'/usr/lib/python2.5/site-packages/PIL'、'/usr/lib/python2.5/ site-packages/gst-0.10'、'/var/lib/python-support/python2.5'、'/usr/lib/python2.5/site-packages/gtk-2.0'、'/var/lib/python -support/python2.5/gtk-2.0', '/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode']
I am trying to install sorl.thumbnail but am getting the following error message:
'thumbnail' is not a valid tag library: Could not load template library from django.templatetags.thumbnail, No module named PIL
This error popped up in this question as well
need help solving sorl-thumbnail error: "'thumbnail' is not a valid tag library:"
but the solution offered there is no good for me. The solution was to append the project folder to all imports in the sorl files. I want to keep my apps separate from the project they are in for obvious reasons.
I have placed the sorl folder in my project folder
I have placed 'sorl.thumbnaills' under installed apps
and finally placed {% load thumbnail %} in base.html
$python2.5
>>>import PIL
>>>import sorl
These work.
Using python2.5, on ubuntu 9.04 with django 1.1 with appengine-patch
To try some other things out i placed in settings.py file:
import sys
sys.path.append("/home/danielle/bu3/mysite/sorl/thumbnail")
But that didnt work either.
Some more help would be appreciated ... how should i change my path?
current path (without above mentioned import):
['/home/danielle/bu3/mysite', '/home/danielle/bu3/mysite/common', '/home/danielle/bu3/mysite/common/appenginepatch/appenginepatcher/lib', '/home/danielle/bu3/mysite/common/zip-packages/django-1.1.zip', '/home/danielle/bu3/mysite/common/appenginepatch', '/usr/local/google_appengine', '/usr/local/google_appengine/lib/antlr3', '/usr/local/google_appengine/lib/yaml/lib', '/usr/local/google_appengine/lib/django', '/usr/local/google_appengine/lib/webob', '/home/danielle/bu3/mysite', '/usr/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg', '/usr/lib/python2.5/site-packages/ZopeSkel-2.10-py2.5.egg', '/usr/lib/python2.5/site-packages/virtualenv-1.3.2-py2.5.egg', '/usr/lib/python2.5/site-packages/pip-0.3.1-py2.5.egg', '/usr/lib/python2.5/site-packages/virtualenvwrapper-1.12-py2.5.egg', '/usr/lib/python2.5/site-packages/PyYAML-3.08-py2.5-linux-i686.egg', '/usr/lib/python2.5/site-packages/xlutils-1.3.0-py2.5.egg', '/usr/lib/python2.5/site-packages/errorhandler-1.0.0-py2.5.egg', '/usr/lib/python2.5/site-packages/xlwt-0.7.1-py2.5.egg', '/usr/lib/python2.5/site-packages/xlrd-0.7.0-py2.5.egg', '/usr/lib/python2.5/site-packages/Fabric-0.0.9-py2.5.egg', '/usr/lib/python2.5/site-packages/multitask-0.2.0-py2.5.egg', '/usr/lib/python2.5/site-packages/logilab.pylintinstaller-0.15.2-py2.5.egg', '/usr/lib/python2.5/site-packages/pylint-0.15.2-py2.5.egg', '/usr/lib/python2.5/site-packages/clonedigger-1.0.9_beta-py2.5.egg', '/usr/lib/python2.5/site-packages/yolk-0.4.1-py2.5.egg', '/usr/lib/python2.5/site-packages/MySQL_python-1.2.3c1-py2.5-linux-i686.egg', '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages/Numeric', '/usr/lib/python2.5/site-packages/PIL', '/usr/lib/python2.5/site-packages/gst-0.10', '/var/lib/python-support/python2.5', '/usr/lib/python2.5/site-packages/gtk-2.0', '/var/lib/python-support/python2.5/gtk-2.0', '/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode']
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的问题是否有拼写错误?您拼写错误了“thumbnails” - 对于已安装的应用程序,您有两个 l,即
'sorl.thumbnaills'
而不是
如果您运行
sync.db
它会返回错误?Is is a typo in your question? You have mis-spelled 'thumbnails' - for the installed apps you have two l's, i.e.
'sorl.thumbnaills'
rather than
if you run
sync.db
does it return an error?(编辑这个,因为我没有仔细阅读)
我认为
django.templatetags.thumbnail
不是你的缩略图模板标签应该加载的地方......我想,如果你把它放在在您的项目文件夹中,它将是myproject.sorl.thumbnail.templatetags.thumbnail
。至于:
似乎无法加载PIL,即使
import PIL
有效,您是否手动安装了Python 成像库 (PIL) - 在我知道的大多数系统上默认情况下通常不存在。您是否尝试过在
/usr/lib/python2.6/site-packages/
路径上创建符号链接并尝试以这种方式利用sorl
?我在 Ubuntu 上使用没有任何问题。(Editing this, since I didn't read carefully enough)
django.templatetags.thumbnail
is not, I think, where your thumbnail templatetags should be loading from ... I would think, if you put it in your project folder, it would bemyproject.sorl.thumbnail.templatetags.thumbnail
.As for the the:
Seems that it can't load PIL, even though
import PIL
works, did you manually install the Python Imaging Library (PIL) - which is usually not present by default on most systems I know.Have you tried creating a symlink to on your
/usr/lib/python2.6/site-packages/
path and attempting to utilizesorl
that way? I am using it on Ubuntu without a problem.看来我只是在 stackoverflow 上犯了拼写错误,在我的设置中:
我认为顺序并不重要。我正在尝试在应用程序引擎上运行它,所以我不需要执行同步数据库,因为它不会在应用程序引擎上执行任何操作。
It seems i only made the typo here on stackoverflow, in settings i have:
I assume the order doesn't matter. I'm trying to run this on app engine so i haven't needed to do a syncdb as that doesn't do anything on app engine.