AH01215:ImportError:没有名为PIL的模块:从apache2 config运行时,python脚本无法识别PIL

2024-06-01 05:50:27 发布

您现在位置:Python中文网/ 问答频道 /正文

你做了什么?在

我已经在apache中进行了配置httpd.conf-mod启用_cgi.so.公司和httpd-vhosts.conf公司是的

在httpd中,主机有以下的持续时间。基本上我正在尝试捕获所有的/图像/模式,读取使用索引.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

在索引.py我只是试图通过导入图像来启动脚本。它根本不起作用,也就是说根本不认识。从spyder、pycharm或命令行的python2/python3接口导入相同的PIL。在

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

^{pr2}$

你以为会发生什么?在

python脚本来识别PIL但它不识别。我已经多次卸载PIL-SIMD并重新安装,但它不起作用。 虽然我有python2和python3,但默认使用python2,apachecgi接口也是。在

到底发生了什么?在

我在apache日志中捕捉到以下错误。在

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

你在用什么版本的枕头和Python?在

Python 2.7.12版 枕头SIMD 枕头SIMD(4.0.0.post0)

如果这个问题无法解决,请帮助我,我必须完全远离python。在


Tags: py脚本comlogindexpilexamplevar
1条回答
网友
1楼 · 发布于 2024-06-01 05:50:27

所有-我也尝试了Dan Dev&others提供的链接。詹姆斯,我只是用这个来调整图像的大小,然后回传和截获图像调用。所有其他请求将通过Apache2发送到其他应用服务器。在

我刚印了一张系统路径为了得到跟随。我在Python身上找不到任何东西。请注意,即使在这里,如果我注释掉并从操作系统名称空间输出图像,它也能工作。当我试着用枕头时,问题就发生了。我卸载/重新安装了python和pillow simd,但这个问题仍然存在。在

我也试过了!/usr/bin/python选项也不起作用。我使用mac 10.5。*

['/private/var/www/images','/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip','/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7','/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat达尔文','/系统/库/框架/Python.framework/Versions/2.7/lib/python2.7/plat mac','/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat mac/lib scriptpackages','/System/lib/Frameworks/Python.framework/Versions/2.7/Extras/lib/python','/System/lib/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib tk','/系统/库/框架/Python.framework/Versions/2.7/lib/python2.7/lib旧','/System/lib/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib dynload','/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC','/Library/python/2.7/site packages']

相关问题 更多 >