Skip to main content
 首页 » 编程设计

python之Ubuntu 上 PIL 的问题

2023年11月22日20虾米姐

当我尝试在我的 Ubuntu-12* 上运行一些 .py 文件时(它是通过 VirtualBox 模拟的)我收到了消息:

raise IOError("decoder %s not available" % decoder_name) 
IOError: decoder jpeg not available 

在寻找答案后,我在这里找到了一些解决此问题的潜在方法:PIL /JPEG Library / Help!特别是(我想)这里:https://stackoverflow.com/a/12301138/1522479 ...以下是哪里说的:

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: 
 
for x64 OS 
 
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 

但是当我尝试这个解决方案时,我没有得到想要的结果。 这里是日志的结尾(抱歉,这么大一 block ):

PIL 1.1.7 SETUP SUMMARY 
--------------------------------------------------------------------     
version       1.1.7 
 
platform      linux2 2.7.4 (default, Apr 19 2013, 18:28:01) 
 
              [GCC 4.7.3]     
--------------------------------------------------------------------     
*** TKINTER support not available (Tcl/Tk 8.5 libraries needed)     
--- JPEG support available     
*** ZLIB (PNG/ZIP) support not available     
*** FREETYPE2 support not available     
*** LITTLECMS support not available     
-------------------------------------------------------------------- 
 
To add a missing option, make sure you have the required     
library, and set the corresponding ROOT variable in the     
setup.py script. 
 
To check the build, run the selftest.py script.     
running build_scripts     
creating build/scripts-2.7     
copying and adjusting Scripts/pilfile.py -> build/scripts-2.7     
copying and adjusting Scripts/pildriver.py -> build/scripts-2.7     
copying and adjusting Scripts/pilconvert.py -> build/scripts-2.7     
copying Scripts/pilfont.py -> build/scripts-2.7     
copying and adjusting Scripts/pilprint.py -> build/scripts-2.7     
changing mode of build/scripts-2.7/pilfile.py from 664 to 775     
changing mode of build/scripts-2.7/pildriver.py from 664 to 775     
changing mode of build/scripts-2.7/pilconvert.py from 664 to 775     
changing mode of build/scripts-2.7/pilfont.py from 664 to 775     
changing mode of build/scripts-2.7/pilprint.py from 664 to 775     
running install_lib     
creating /usr/local/lib/python2.7/dist-packages/PIL 
 
 
 
error: could not create '/usr/local/lib/python2.7/dist-packages/PIL': Permission denied 
 
 
---------------------------------------- 
Command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build-nupic/PIL/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-p6ZHoT-record/install-record.txt --single-version-externally-managed failed with error code 1 in /tmp/pip-build-nupic/PIL 
Storing complete log in /home/nupic/.pip/pip.log  
nupic@nupic-vm:/$ 

另一个问题是我没有使用 Linux(几个月前我被迫开始使用它),所以我不知道如何处理这种情况。我需要帮助,真的。 附言如果重要的话——在我尝试运行 .py 文件之前,我已经安装了 pygame(成功)。

请您参考如下方法:

error: could not create '/usr/local/lib/python2.7/dist-packages/PIL': Permission denied 

建议你有权限问题,如果你真的想在系统范围内安装PIL,使用:

sudo pip install PIL 

您还可以安装到用户拥有的目录:

sudo pip install --install-option="--prefix=$PREFIX_PATH" PIL 

或者,最好安装在 virtualenv 中,