首页 文章

Django和Pillow

提问于
浏览
2

在我的Django项目中,我尝试运行服务器:

python manage.py runserver 9000

但我有这个错误:

错误:api.NameOfProject.profile_picture:(fields.E210)无法使用ImageField,因为未安装Pillow . 提示:通过https://pypi.python.org/pypi/Pillow获取枕头或运行命令“pip install pillow” . api.Photo.photo :( fields.E210)无法使用ImageField,因为未安装Pillow . 提示:通过https://pypi.python.org/pypi/Pillow获取枕头或运行命令“pip install pillow” .

我在我的Mac OSX系统上安装Pillow:

pip install pillow

但它是一样的......我也尝试用Homebrew安装......

2 回答

  • 0

    有类似的问题,我的解决方案更简单:

    Apparently packages PIL and Pillow can't coexist. If you want to use Pillow you first have to uninstall PIL and then install Pillow .

    如果您使用的是Mac,则必须使用brew安装一些库 . 下面提到的是一系列步骤:

    $pip uninstall PIL
    $brew install libtiff libjpeg webp little-cms2
    $pip install Pillow
    

    要测试枕头是否已安装并准备使用,请打开python interpreter并尝试导入以下内容:

    >>> from PIL import Image
    

    *请注意,该库仍然显示PIL,但现在它是从Pillow而不是PIL导入的 .

    如果你能够成功导入那么你很高兴(很可能你不必担心设置PYTHONPATH或32/64位安装)

    资料来源:http://pillow.readthedocs.org/installation.html

  • 1

    我解决了我的问题 .

    我在这里下载源代码:https://pypi.python.org/pypi/Pillow并安装了枕头: sudo python setup.py install

    如果有人能向我解释自制软件的问题是什么 .

相关问题