Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import Error. No module named Image #89

Closed
jl2035 opened this issue Aug 14, 2015 · 7 comments
Closed

Import Error. No module named Image #89

jl2035 opened this issue Aug 14, 2015 · 7 comments

Comments

@jl2035
Copy link

jl2035 commented Aug 14, 2015

I have found many questions on stackoverflow about this, but I guess I'm not smart enough to help myself with any of the solutions they provide. I have followed this documentation http://django-simple-captcha.readthedocs.org/en/latest/usage.html very precisely, but I must be just unlucky.

After adding this:

urlpatterns += patterns('',
    url(r'^captcha/', include('captcha.urls')),
)

to urls.py I'm getting this: ImportError at / No module named Image

I have no idea what's going on. The stack trace does not tell me much :)

Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response

  1.             resolver_match = resolver.resolve(request.path_info)
    
    File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in resolve
  2.         for pattern in self.url_patterns:
    
    File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in url_patterns
  3.     patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
    
    File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in urlconf_module
  4.         self._urlconf_module = import_module(self.urlconf_name)
    
    File "/usr/lib/python2.7/importlib/init.py" in import_module
  5. **import**(name)
    
    File "/home/wuser/mysite/mysite/urls.py" in
  6. url(r'^captcha/', include('captcha.urls')),
    File "/usr/local/lib/python2.7/dist-packages/django/conf/urls/init.py" in include
  7.     urlconf_module = import_module(urlconf_module)
    
    File "/usr/lib/python2.7/importlib/init.py" in import_module
  8. **import**(name)
    
    File "/usr/local/lib/python2.7/dist-packages/captcha/urls.py" in
  9. from captcha import views
    File "/usr/local/lib/python2.7/dist-packages/captcha/views.py" in
  10. import Image
    

Exception Type: ImportError at /
Exception Value: No module named Image

@mbi
Copy link
Owner

mbi commented Aug 14, 2015

did you pip install Pillow?

@jl2035
Copy link
Author

jl2035 commented Aug 14, 2015

I can't! This is the end of output:

x86_64-linux-gnu-gcc: error: build/temp.linux-x86_64-2.7/libImaging/BoxBlur.o: No such file or directory

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1


Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;file='/tmp/pip_build_root/Pillow/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /tmp/pip-QLeVd6-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/Pillow
Storing debug log for failure in /root/.pip/pip.log

@mbi
Copy link
Owner

mbi commented Aug 14, 2015

Uhm, if you're on Debian or Ubuntu:

apt-get -y install libz-dev libjpeg-dev libfreetype6-dev python-dev

Does this help? Pillow is a strict requirement, that is why you're getting the Import Image error

@jl2035
Copy link
Author

jl2035 commented Aug 14, 2015

whoa! Thanks for the awesomeness. This trick could be included in the docs btw...

@jl2035 jl2035 closed this as completed Aug 14, 2015
@mbi
Copy link
Owner

mbi commented Aug 14, 2015

Good point, will add that

@tanuka72
Copy link

"apt-get -y install libz-dev libjpeg-dev libfreetype6-dev python-dev"
What is the equivalent on CentOS?

I have Pillow 2.6.1 installed, but when I try to start Django (over Apache using mod_wsgi), I get the following traceback

[23/Dec/2015 14:54:14] ERROR [django.request:231] Internal Server Error: /
Traceback (most recent call last):
File "/home/syt_admin/.virtualenvs/vishwaas_env/lib/python2.7/site-packages/django/core/handlers/base.py", line 98, in get_response
resolver_match = resolver.resolve(request.path_info)
File "/home/syt_admin/.virtualenvs/vishwaas_env/lib/python2.7/site-packages/django/core/urlresolvers.py", line 338, in resolve
for pattern in self.url_patterns:
File "/home/syt_admin/.virtualenvs/vishwaas_env/lib/python2.7/site-packages/django/core/urlresolvers.py", line 367, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/syt_admin/.virtualenvs/vishwaas_env/lib/python2.7/site-packages/django/core/urlresolvers.py", line 361, in urlconf_module
self._urlconf_module = import_module(self.urlconf_name)
File "/usr/local/lib/python2.7/importlib/init.py", line 37, in import_module
import(name)
File "/home/syt_admin/projects/vishwaas/vishwaas_django/vishwaas_django/urls.py", line 27, in
url(r'^captcha/', include('captcha.urls')),
File "/home/syt_admin/.virtualenvs/vishwaas_env/lib/python2.7/site-packages/django/conf/urls/init.py", line 28, in include
urlconf_module = import_module(urlconf_module)
File "/usr/local/lib/python2.7/importlib/init.py", line 37, in import_module
import(name)
File "/home/syt_admin/.virtualenvs/vishwaas_env/lib/python2.7/site-packages/captcha/urls.py", line 2, in
from captcha import views
File "/home/syt_admin/.virtualenvs/vishwaas_env/lib/python2.7/site-packages/captcha/views.py", line 21, in
import Image
ImportError: No module named Image

The same code worked on Windows and I was able to see the CAPTCHA in my ModelForms.

@249143979
Copy link

Mac OX:
run:brew install Homebrew/python/pillow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants