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

Python 3.2 Encoder JPEG not available #41

Closed
Sapphire64 opened this issue Jan 19, 2013 · 7 comments
Closed

Python 3.2 Encoder JPEG not available #41

Sapphire64 opened this issue Jan 19, 2013 · 7 comments

Comments

@Sapphire64
Copy link
Contributor

Looks like this is old-school well known problem, but:

running build_ext
--------------------------------------------------------------------
SETUP SUMMARY (Pillow 1.7.8 / PIL 1.1.7)
--------------------------------------------------------------------
version      1.7.8
platform     linux2 3.2.3 (default, Jun 25 2012, 23:10:56)
             [GCC 4.7.1]
--------------------------------------------------------------------
*** TKINTER support not available

--- JPEG support available      <<<<<<<<<<< WOT? O_o
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
*** LITTLECMS support not available

--------------------------------------------------------------------

I've tried many advices from web like:

sudo apt-get install libjpeg libjpeg-dev libfreetype6 libfreetype6-dev zlib1g-dev

and

# ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib
# ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib
# ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib

Without any success.

System:
Debian wheezy/sid amd64
Python 3.2.3 in virtualenv

PNG encoder works fine.

Tests:

--------------------------------------------------------------------
PIL 1.1.7 TEST SUMMARY 
--------------------------------------------------------------------
Python modules loaded from ./PIL
Binary modules loaded from .
--------------------------------------------------------------------
*** PIL CORE support not installed
*** TKINTER support not installed
--- JPEG support ok
--- ZLIB (PNG/ZIP) support ok
*** FREETYPE2 support not installed
*** LITTLECMS support not installed
--------------------------------------------------------------------
Running selftest:
--- 57 tests passed.
Traceback (most recent call last):
  File "/path/to/venv/lib/python3.2/site-packages/Pillow-1.7.8-py3.2-linux-x86_64.egg/PIL/Image.py", line 381, in _getencoder
    encoder = getattr(core, encoder_name + "_encoder")
AttributeError: 'module' object has no attribute 'jpeg_encoder'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/path/to/venv/lib/python3.2/site-packages/tornado-2.4.1-py3.2.egg/tornado/web.py", line 1021, in _stack_context_handle_exception
    raise_exc_info((type, value, traceback))
  File "/path/to/venv/lib/python3.2/site-packages/tornado-2.4.1-py3.2.egg/tornado/util.py", line 90, in raise_exc_info
    raise exc_info[1].with_traceback(exc_info[2])
  File "/path/to/venv/lib/python3.2/site-packages/tornado-2.4.1-py3.2.egg/tornado/web.py", line 1139, in wrapper
    return method(self, *args, **kwargs)
  File "/path/to/venv/project/project/handlers/DevHandlers.py", line 88, in func
    area.save(admin_image, "JPEG")
  File "/path/to/venv/lib/python3.2/site-packages/Pillow-1.7.8-py3.2-linux-x86_64.egg/PIL/Image.py", line 1448, in save
    save_handler(self, fp, filename)
  File "/path/to/venv/lib/python3.2/site-packages/Pillow-1.7.8-py3.2-linux-x86_64.egg/PIL/JpegImagePlugin.py", line 470, in _save
    ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)])
  File "/path/to/venv/lib/python3.2/site-packages/Pillow-1.7.8-py3.2-linux-x86_64.egg/PIL/ImageFile.py", line 451, in _save
    e = Image._getencoder(im.mode, e, a, im.encoderconfig)
  File "/path/to/venv/lib/python3.2/site-packages/Pillow-1.7.8-py3.2-linux-x86_64.egg/PIL/Image.py", line 385, in _getencoder
    raise IOError("encoder %s not available" % encoder_name)
IOError: encoder jpeg not available
@d-schmidt
Copy link
Contributor

The selftest had an error and is showing wrong results, the other thing is just strange. I should work.

@laurentpayot
Copy link

Exactly the same bug here with Python 3.2.3 and Ubuntu 12.10. I installed libjpeg8 and libjpeg8-dev to enable JPEG support, but there is an error saying jpeg encoder is not available.

@laurentpayot
Copy link

PS: The bug only is only present on my AMD64 machine, jpeg encoder does work on my Intel32 based laptop (also with Python 3.2.3 and Ubuntu 12.10).

@Sapphire64
Copy link
Contributor Author

Well, this can explain a lot I think. I can confirm that my system is Intel with AMD64 architecture too.

Maybe expected that jpeg libs must be in folder like /usr/lib/i686-linux-gnu/libjpeg.so, not where they are now (/usr/lib/x86_64-linux-gnu/libjpeg.so)?

@Sapphire64
Copy link
Contributor Author

Yeap, look here:

Python 3.2.3 (default, Jun 25 2012, 23:10:56) 
[GCC 4.7.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> platform.processor()
''

And now check this in setup.py:

if platform.processor() == "x86_64":
                _add_directory(library_dirs, "/lib64")
                _add_directory(library_dirs, "/usr/lib64")
                _add_directory(library_dirs, "/usr/lib/x86_64-linux-gnu")
            else:
                _add_directory(library_dirs, "/usr/lib/i386-linux-gnu")

@laurentpayot
Copy link

I just applied your setup.py modifications and after a Pillow complete re-installation (removing build directory etc.) the jpeg encoder is finally working on my AMD64 machine. Thanks a lot!

@Sapphire64
Copy link
Contributor Author

I'm glad to hear that. Hope other distributions users will check this patch and it will be merged. Today I was moving my project to Py3.3 server and for another time I have faced this problem. Thanks for noting 'removing build directory', this helped me after I have installed libjpeg62-dev. After all, I hope Pillow's installation process will be improved at least with more friendly error messages.

aclark4life added a commit that referenced this issue Mar 5, 2013
Py3k libraries path fix (issue #41)
hugovk added a commit that referenced this issue Feb 16, 2020
radarhere pushed a commit to radarhere/Pillow that referenced this issue Sep 24, 2023
…uild

MRG: refactor OS X build to same system as Linux
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