PIL library not working with apache 2.2

120 views
Skip to first unread message

Sharjeel Ali Shaukat

unread,
Jun 11, 2014, 6:16:47 AM6/11/14
to web...@googlegroups.com, ma...@knysys.com
I m having a problem when running PIL library with apache i always get  this error

global name 'ImageGrab' is not defined

please help me regarding this issue

LightDot

unread,
Jun 11, 2014, 7:15:54 AM6/11/14
to web...@googlegroups.com, ma...@knysys.com
Show us some code. How are you importing the library, how are you using it?

Regards

Sharjeel Ali Shaukat

unread,
Jun 11, 2014, 7:32:59 AM6/11/14
to web...@googlegroups.com, ma...@knysys.com

I have installed it using PIL binary file 

from PIL import ImageGrab

this is how i m calling the ImageGrab from PIL this line always give me error after running it on apache server

at

unread,
Jun 11, 2014, 8:39:38 AM6/11/14
to web...@googlegroups.com, ma...@knysys.com
facing same issue both on ubuntu and windows7:

Trying:
from PIL import ImageGrab


Getting:
ImportError: No module named PIL

and the strange thing is no errors on:
from PIL import Image

Any help?
Thanks

Niphlod

unread,
Jun 11, 2014, 9:21:33 AM6/11/14
to web...@googlegroups.com, ma...@knysys.com
verify that apache is running the same python version you're running and has PIL installed. This is a well-known issue, but has nothing to do with web2py.

at

unread,
Jun 11, 2014, 9:41:19 AM6/11/14
to web...@googlegroups.com, ma...@knysys.com

Thanks for the swift reply.
I've tried installing PIL as well as Pillow, using binary install on windows and using pip and apt-get install on ubuntu.

Any quick way to verify which python version is being used by apache?

Regards

Niphlod

unread,
Jun 11, 2014, 12:08:43 PM6/11/14
to web...@googlegroups.com, ma...@knysys.com
this is the relevant excerpt

Note that the version of Python from which this baseline environment is created must be the same version of Python that mod_wsgi was compiled for. It is not possible to mix environments based on different major/minor versions of Python

Usually people need to recompile mod_wsgi manually passing the right python homedir. 
a good method to check in "debian-like" OS is to run

 ldd /usr/lib/apache2/modules/mod_wsgi.so

and see what pops up

BTW: this is one among MAAANY reasons apache + mod_wsgi has been largely superseeded . Too many issues and too little flexibility in respect of other simpler and more performant alternatives.

at

unread,
Jun 11, 2014, 2:29:12 PM6/11/14
to web...@googlegroups.com, ma...@knysys.com


On Wednesday, 11 June 2014 21:08:43 UTC+5, Niphlod wrote:
this is the relevant excerpt

Note that the version of Python from which this baseline environment is created must be the same version of Python that mod_wsgi was compiled for. It is not possible to mix environments based on different major/minor versions of Python

Usually people need to recompile mod_wsgi manually passing the right python homedir. 
a good method to check in "debian-like" OS is to run

 ldd /usr/lib/apache2/modules/mod_wsgi.so

and see what pops up

Thank you Niphlod for the informative post. I'll further explore it.
 
BTW: this is one among MAAANY reasons apache + mod_wsgi has been largely superseeded . Too many issues and too little flexibility in respect of other simpler and more performant alternatives.

What are other alternatives? really interested to know about it.
Thanks

 

Niphlod

unread,
Jun 11, 2014, 2:56:42 PM6/11/14
to web...@googlegroups.com, ma...@knysys.com
lighttpd and nginx for the webserver part, fastcgi, sgci or uwsgi for the python one.
Reply all
Reply to author
Forward
0 new messages