运行django-cms演示页时出错

时间:2014-04-15 08:27:52

标签: django ubuntu-12.04 pip django-cms pillow

我尝试了安装django-cms的所有程序,之后当我尝试运行一个演示页面时,我收到以下错误。

(djvenv2)shan@shan:~/workspace/projects/djvenv$ pip freeze
Django==1.6.2
PIL==1.1.7
Pillow==2.4.0
South==0.8.4
argparse==1.2.1
dj-database-url==0.3.0
django-classy-tags==0.5.1
django-cms==3.0
django-mptt==0.6.0
django-sekizai==0.7
djangocms-admin-style==0.2.2
djangocms-installer==0.4.1
html5lib==0.999
six==1.6.1
wsgiref==0.1.2

(djvenv2)shan@shan:~/workspace/projects/djvenv$ djangocms -p . my_demo
Database configuration (in URL format) [default sqlite://localhost/project.db]:
django CMS version (choices: 2.4, 3.0, stable, develop) [default stable]:
Django version (choices: 1.4, 1.5, 1.6, stable) [default 1.5]:
Activate Django I18N / L10N setting (choices: yes, no) [default yes]:
Install and configure reversion support (choices: yes, no) [default yes]:
Languages to enable. Option can be provided multiple times, or as a comma separated list: en
Optional default time zone [default America/Chicago]:
Activate Django timezone support (choices: yes, no) [default yes]:
Activate CMS permission management (choices: yes, no) [default yes]:
Use Twitter Bootstrap Theme (choices: yes, no) [default no]: yes
Load a starting page with examples after installation (choices: yes, no) [default no]: yes
INFO: Starting new HTTPS connection (1): pypi.python.org
Traceback (most recent call last):
  File "/home/shan/workspace/venv/djvenv2/bin/djangocms", line 9, in <module>
    load_entry_point('djangocms-installer==0.4.1', 'console_scripts', 'djangocms')()
  File "/home/shan/workspace/venv/djvenv2/local/lib/python2.7/site-packages/djangocms_installer/main.py", line 24, in execute
    install.check_install(config_data)
  File "/home/shan/workspace/venv/djvenv2/local/lib/python2.7/site-packages/djangocms_installer/install/__init__.py", line 52, in check_install
    raise EnvironmentError("\n".join(errors))
EnvironmentError: Pillow is not compiled with JPEG support, see 'Libraries installation issues' documentation section.

4 个答案:

答案 0 :(得分:20)

向Pillow添加JPEG支持,在Ubuntu中,您可以执行以下操作:

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

# Link the libraries for Pillow to find them:

sudo ln -s /usr/lib/`uname -i`-linux-gnu/libfreetype.so /usr/lib/
sudo ln -s /usr/lib/`uname -i`-linux-gnu/libjpeg.so /usr/lib/
sudo ln -s /usr/lib/`uname -i`-linux-gnu/libz.so /usr/lib/

# reinstall Pillow (In case you have Pillow already installed)
pip install --upgrade --force-reinstall pillow

答案 1 :(得分:2)

安装所需的库:

http://pillow.readthedocs.org/en/latest/installation.html#linux-installation

然后在virtualenv中卸载并重新安装Pillow

pip uninstall Pillow
pip install --no-cache-dir Pillow

答案 2 :(得分:2)

我实际上在这里找到了所选择的解决方案,非常有帮助。我还发现djangcms安装程序需要特定版本的Pillow,这导致它无论出于何种原因都没有拿起JPEG模块。在撰写本文时,它需要Pillow==2.8.0,但pip --upgrade正在安装的最新版本是2.9.x.我运行了pip install --no-cache-dir --upgrade --force-reinstall pillow==2.8.0,这似乎满足了djangocms安装程序的要求,因此它将保持JPEG兼容性。

您可以通过在virtualenv中打开python shell来验证是否已安装JPEG支持。

from PIL import Image

i = Image.open('/path/to/a.jpg')
i.load()

如果没有JPEG支持,您将获得加载图像的句柄或异常。

所以pip成功安装了一个支持JPEG的Pillow包,但是一旦我运行djangocms安装程序,它就会用没有JPEG支持的Pillow包替换它。您需要匹配djangocms安装程序想要的Pillow版本。我不知道该配置在哪里,但您可以在安装失败后使用pip freezepip list找出它。

希望这有助于某人。

答案 3 :(得分:1)

我在BitNami LAMP虚拟机下面临同样的问题,并且无法通过链接Pillow的丢失文件来解决它。最后,我解决了它:

首先找到lib

(venv)...$ find 2>/dev/null / -name libz.so
/opt/bitnami/common/lib/libz.so

现在将lib目录添加到pip

(venv)...$ pip install --global-option=build_ext --global-option="-L/opt/bitnami/common/lib" --global-option="-I/opt/bitnami/common/include" --upgrade --force-reinstall pillow

它有效:

--------------------------------------------------------------------
PIL SETUP SUMMARY
--------------------------------------------------------------------
version      Pillow 2.7.0
platform     linux2 2.7.6 (default, Mar 22 2014, 22:59:56)
             [GCC 4.8.2]
--------------------------------------------------------------------
*** TKINTER support not available
--- JPEG support available
*** OPENJPEG (JPEG2000) support not available
--- ZLIB (PNG/ZIP) support available
--- LIBTIFF support available
--- FREETYPE2 support available
*** LITTLECMS2 support not available
*** WEBP support not available
*** WEBPMUX support not available
--------------------------------------------------------------------

另见python pip specify a library directory and an include directory