AH01215:ImportError:没有名为PIL的模块: - 从apache2 config

时间:2017-03-28 15:55:02

标签: python pillow

你做了什么?

我已在apache httpd.conf中配置 - 启用mod_cgi.so和httpd-vhosts.conf。

在httpd-vhosts中有以下配置。基本上我试图捕获所有/ images / pattern,read使用index.py脚本进行该过程并返回image / jpeg内容。

<VirtualHost *:80>
ServerAdmin abc.xyz@gmail.com
ServerName www.groc-example.com
ServerAlias groc-example.com
Alias "/images/" "/var/www/images/"
DirectoryIndex index.py
ErrorLog "/private/var/log/apache2/groc-example-images-error_log"
CustomLog "/private/var/log/apache2/groc-access-log" common
<Directory "/var/www/images/">
Options +ExecCGI
Allow from all
Require all granted
ForceType text/html
AddHandler cgi-script .py

在index.py中,我只是尝试通过尝试导入图像来启动脚本。它是最重要的工作,即完全认可。 PIL的相同导入适用于spyder或pycharm或命令行中的python2 / python3接口。

如果我删除PIL import语句,html将工作或打印到浏览器。

#! /usr/bin/env python
from PIL import Image

print ""
print "hello world"
print "--"
print ""

您期望发生什么?

python脚本识别PIL但它不识别。我已多次卸载PIL-SIMD并重新安装,但它无法正常工作。 虽然我有python2和python3,但默认使用python2,因此是apache CGI接口。

究竟发生了什么?

我在apache日志中捕获了以下错误。

AH01215: from PIL import Image: /var/www/images/index.py
AH01215: ImportError: No module named PIL: /var/www/images/index.py

您使用的是哪种版本的Pillow和Python?

Python 2.7.12 枕头SIMD Pillow-SIMD(4.0.0.post0)

请帮助,如果这不解决,我必须彻底摆脱python。

1 个答案:

答案 0 :(得分:0)

全部 - 我尝试过Dan-Dev&amp; amp;提供的链接。其他人也是。詹姆斯,我只使用它来调整图像大小并发回和截取只有图像的调用。所有其他请求将通过Apache2发送给其他Appserver。

我刚刚打印了一个sys.path来获得关注。 PYTHONPATH我无法得到任何东西。请注意,即使在这里,如果我注释掉并从os命名空间输出图像,它也可以。当我尝试枕头时会出现问题。我卸载/重新安装了python和amp;枕头模拟,但这个问题仍然存在。

我也尝试过#!/ usr / bin / python选项,但它不起作用。我在mac 10.5。*

['/ private / var / www / images','/ System / Library / Frameworks / Pepy.framework / Version / 2.7 / lib / python27.zip','/ System / Library / Frame /Python.framework /版本/ 2.7 / lib / python2.7','/ System / Library / Frame /Python.framework / Version / 7.7 / lib / python2.7 / plat-Darwin','/ System / Library / Frame /Python.framework /版本/ 2.7 / lib / python2.7 / plat-mac','/ System / Library / Frameworks / Python.framework / Version / 1.7 / lib / python2.7 /plat-make / lib -scriptpackages','/ System / Library / Frameworks / Python.framework / Versions / 2.7 / Extras / lib / python','/ System / Library / Frame /Python.framework / Version / 7.7 / lib / python2.7 / lib -tk','/ System / Library / Frameworks / Python.framework / Versions / 2.7 / lib / python2.7 / lib-old','/ System / Library / Frame /Python.framework / Version / 2.7 / lib / python2.7 / lib-dadload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC','/ Library /Python / 2.7 / site-package']

相关问题