使用libjpeg在virtualenv上安装pil

时间:2022-11-08 00:25:37

Currently I'm installing PIL into my virtual env as follows:

目前我正在将PIL安装到我的虚拟env中,如下:

pip install -E . -r ./releases/%s/requirements.txt

where requirements.txt contains:

需求的地方。txt包含:

pil

I can upload png images but not jpeg images currently. From reading on the web it seems i may need libjpeg decoder? Am i installing pil incorrectly? What is the proper way to install pil for django in a virtual env with libjpeg?

我可以上传png图片,但目前没有jpeg图片。从网上阅读看来,我可能需要libjpeg解码器?我安装pil错误吗?在使用libjpeg的虚拟env中安装django的正确方法是什么?

6 个解决方案

#1


14  

You should install the libraries that others recommended but most importantly you should tell PIL where to find them. Edit the setup.py so that

您应该安装其他人推荐的库,但最重要的是您应该告诉PIL在哪里找到它们。编辑设置。py这样

    JPEG_ROOT = None 

becomes

就变成了

JPEG_ROOT = libinclude("/usr/lib") 

I found that the easiest way was to download the source with pip but not install:

我发现最简单的方式是用pip下载源代码,而不是安装:

 pip install --no-install PIL

edit the setup (inside the build directory of the virtual environment) and the install

编辑设置(在虚拟环境的构建目录中)和安装

 pip install PIL

you can find some more information in my blog

你可以在我的博客里找到更多的信息。

You can also try pillow which seems to do great job with little hassle (pip install pillow)

你也可以尝试枕头,似乎做得很好,没有什么麻烦(pip安装枕头)

#2


10  

On Ubuntu precise, PIL doesn't find the jpeg library files, even once they are installed. The easiest way to fix this is to make a symlink after you have installed the jpeg dev package. So, I needed an extra step:

在Ubuntu precision上,PIL没有找到jpeg库文件,即使安装了它们。修复这个问题的最简单方法是在安装jpeg dev包之后创建一个符号链接。所以,我需要额外的步骤:

pip uninstall PIL
sudo apt-get install libjpeg8-dev
sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib
pip install PIL

#3


8  

For Ubuntu 11.04, what finally worked for me is:

对于Ubuntu 11.04来说,最终对我起作用的是:

pip uninstall PIL
sudo apt-get install libjpeg8-dev
pip install PIL

The Python Imaging Library (PIL) seems really picky about version and location of the jpeg libraries. And because PIL is written in C and compiled, you need the development versions of the library in addition to the runtime versions.

Python映像库(PIL)似乎对jpeg库的版本和位置非常挑剔。而且由于PIL是用C编写并编译的,所以除了运行时版本之外,您还需要库的开发版本。

The situation is so bad the community forked PIL to create a softer version: Pillow: http://pypi.python.org/pypi/Pillow#why-a-fork

情况非常糟糕,社区为了创建一个更软的版本而放弃了PIL: Pillow: http://pypi.python.org/pypi/Pillow#why-a-fork

#4


6  

On OSX, I used the following binary to get libpng and libjpeg simultaneously installed systemwide:

在OSX上,我使用以下二进制文件使libpng和libjpeg在系统范围内同时安装:

libpng & libjpeg for OSX

OSX的libpng和libjpeg

Because I already had PIL installed (via pip on a virtualenv), I ran:

因为我已经安装了PIL(通过一个virtualenv上的pip),所以我运行:

pip uninstall PIL
pip install PIL --upgrade

This resolved the decoder JPEG not available error for me.

这解决了解码器JPEG对我来说不可用的错误。

#5


3  

You must install the libraries:

你必须安装图书馆:

sudo aptitude install libjpeg62 libjpeg62-dev zlib1g-dev

#6


1  

if pip raises an error, try easy_install PIL

如果pip出现错误,请尝试easy_install PIL。

#1


14  

You should install the libraries that others recommended but most importantly you should tell PIL where to find them. Edit the setup.py so that

您应该安装其他人推荐的库,但最重要的是您应该告诉PIL在哪里找到它们。编辑设置。py这样

    JPEG_ROOT = None 

becomes

就变成了

JPEG_ROOT = libinclude("/usr/lib") 

I found that the easiest way was to download the source with pip but not install:

我发现最简单的方式是用pip下载源代码,而不是安装:

 pip install --no-install PIL

edit the setup (inside the build directory of the virtual environment) and the install

编辑设置(在虚拟环境的构建目录中)和安装

 pip install PIL

you can find some more information in my blog

你可以在我的博客里找到更多的信息。

You can also try pillow which seems to do great job with little hassle (pip install pillow)

你也可以尝试枕头,似乎做得很好,没有什么麻烦(pip安装枕头)

#2


10  

On Ubuntu precise, PIL doesn't find the jpeg library files, even once they are installed. The easiest way to fix this is to make a symlink after you have installed the jpeg dev package. So, I needed an extra step:

在Ubuntu precision上,PIL没有找到jpeg库文件,即使安装了它们。修复这个问题的最简单方法是在安装jpeg dev包之后创建一个符号链接。所以,我需要额外的步骤:

pip uninstall PIL
sudo apt-get install libjpeg8-dev
sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib
pip install PIL

#3


8  

For Ubuntu 11.04, what finally worked for me is:

对于Ubuntu 11.04来说,最终对我起作用的是:

pip uninstall PIL
sudo apt-get install libjpeg8-dev
pip install PIL

The Python Imaging Library (PIL) seems really picky about version and location of the jpeg libraries. And because PIL is written in C and compiled, you need the development versions of the library in addition to the runtime versions.

Python映像库(PIL)似乎对jpeg库的版本和位置非常挑剔。而且由于PIL是用C编写并编译的,所以除了运行时版本之外,您还需要库的开发版本。

The situation is so bad the community forked PIL to create a softer version: Pillow: http://pypi.python.org/pypi/Pillow#why-a-fork

情况非常糟糕,社区为了创建一个更软的版本而放弃了PIL: Pillow: http://pypi.python.org/pypi/Pillow#why-a-fork

#4


6  

On OSX, I used the following binary to get libpng and libjpeg simultaneously installed systemwide:

在OSX上,我使用以下二进制文件使libpng和libjpeg在系统范围内同时安装:

libpng & libjpeg for OSX

OSX的libpng和libjpeg

Because I already had PIL installed (via pip on a virtualenv), I ran:

因为我已经安装了PIL(通过一个virtualenv上的pip),所以我运行:

pip uninstall PIL
pip install PIL --upgrade

This resolved the decoder JPEG not available error for me.

这解决了解码器JPEG对我来说不可用的错误。

#5


3  

You must install the libraries:

你必须安装图书馆:

sudo aptitude install libjpeg62 libjpeg62-dev zlib1g-dev

#6


1  

if pip raises an error, try easy_install PIL

如果pip出现错误,请尝试easy_install PIL。