English 中文(简体)
sorl.thumbnail : thumbnail is not a valid tag library?
原标题:

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 ]

问题回答

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

 sorl.thumbnails 

if you run sync.db does it return an error?

(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 be myproject.sorl.thumbnail.templatetags.thumbnail.

As for the the:

No module named PIL

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 utilize sorl that way? I am using it on Ubuntu without a problem.

It seems i only made the typo here on stackoverflow, in settings i have:

INSTALLED_APPS = (
 jquery ,
 blueprintcss ,
 django.contrib.auth ,
 django.contrib.sessions ,
 django.contrib.admin ,
 django.contrib.webdesign ,
 django.contrib.flatpages ,
 django.contrib.redirects ,
 django.contrib.sites ,
 appenginepatcher ,
 ragendja ,
 myapp ,
 registration ,
 mediautils ,
 site_nav ,
 pages ,
 sorl.thumbnail ,
)

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.





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签