0

What did you do?

I have configured in apache httpd.conf - enabling of mod_cgi.so and httpd-vhosts.conf.

In httpd-vhosts have following conifguration. Basically am trying to capture all /images/ pattern, read have that process using a index.py script and return back as image/jpeg content.

<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

In the index.py am just trying to start the script by trying to import the image. It doenst work i.e. recognize at all. The same import of PIL works from python2/python3 interface in spyder or pycharm or commandlines.

If I remove PIL import statement, the html works or prints out to browser.

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

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

What did you expect to happen?

python script to recognize PIL but it doesnt recognize. I have uninstalled PIL-SIMD multiple times and reinstalled but it isnt working. Though I have both python2 and python3, default am using python2 and so is apache CGI interface.

What actually happened?

I capture following error in apache logs.

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

What versions of Pillow and Python are you using?

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

Please help if this wont resolve, I have to completely move away from python.

1 Answers1

0

All - i have tried the links provided by Dan-Dev & others as well. James, am using this only to resize image and send back and intercept calls for only images. All other requests will go to other Appservers through Apache2.

I just printed a sys.path to get following. I am unable to get anything on PYTHONPATH. Note that even here if i comment out and just output the image from os namespace, it works. Issue happens when i try pillow. I uninstalled /reinstalled both python & pillow-simd but still this issue persist.

I also have tried #!/usr/bin/python option as well which doesnt work. I am on 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-darwin', '/System/Library/Frameworks/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/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/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']