Pillow not imported by web2py-win

83 views
Skip to first unread message

Dave S

unread,
Apr 20, 2022, 3:26:48 AM4/20/22
to web2py-users
I want to do some simple image manipulation using Pillow.  I've been using Pillow in a standalone Python27 setup, and now I want to use it within my w2p app.

Since I had done the PIP into the standalone, I copied the files from that site-packages to the web2py/site-packages.  The function that needed to use the package did 

    from PIL import Image

which resulted in the stacktrace:

Traceback (most recent call last):
File "C:\Users\Dave\web2py_win\web2py_win_2.21.1_py27\web2py\gluon\restricted.py", line 219, in restricted
exec(ccode, environment)
File "C:/Users/Dave/web2py_win/web2py_win_2.21.1_py27/web2py/applications/badlist/controllers/default.py", line 2691, in <module>
File "C:\Users\Dave\web2py_win\web2py_win_2.21.1_py27\web2py\gluon\globals.py", line 430, in <lambda>
self._caller = lambda f: f()
File "C:/Users/Dave/web2py_win/web2py_win_2.21.1_py27/web2py/applications/badlist/controllers/default.py", line 1059, in display
img = Image.open(deep_path)
File "C:\Users\Dave\web2py_win\web2py_win_2.21.1_py27\web2py\site-packages\PIL\Image.py", line 2807, in open
if init():
File "C:\Users\Dave\web2py_win\web2py_win_2.21.1_py27\web2py\site-packages\PIL\Image.py", line 427, in init
__import__("PIL.%s" % plugin, globals(), locals(), [])
File "C:\Users\Dave\web2py_win\web2py_win_2.21.1_py27\web2py\gluon\custom_import.py", line 59, in custom_importer
return NATIVE_IMPORTER(name, globals, locals, fromlist, level)
File "C:\Users\Dave\web2py_win\web2py_win_2.21.1_py27\web2py\site-packages\PIL\EpsImagePlugin.py", line 51, in <module>
which = distutils.spawn.find_executable
AttributeError: 'module' object has no attribute 'spawn'

What are my options here, and what is the simplest way to get past this?  Should I

* try to get the appropriate distutils?
* try to run web2py from source on the standalone 2.7?
* try to run web2py-win's 3.x and switch to the matching Pillow?

(I think I have a standalone 3.10 already, but I haven't run Pillow on that)

Thanks for the sage advice.

/dps

Massimo Di Pierro

unread,
May 7, 2022, 2:00:42 AM5/7/22
to web2py-users
can you try "pip install pillow" instead of putting it in C:\Users\Dave\web2py_win\web2py_win_2.21.1_py27\web2py\site-packages Not all packages like to be there and it can create problems.

Nico Zanferrari

unread,
May 8, 2022, 4:55:52 AM5/8/22
to Dave S, web...@googlegroups.com
Hi Dave,

the simplest solution is surely to use web2py from source - and it's even better on py3 if possible.

If you're stick with the frozen app (apart from my simple guide on this at https://github.com/nicozanf/web2py-pyinstaller/blob/master/HOWTO-modules.md), I don't have any special advise - you have to try all the possibilities...
Also, check what happens if you try to import the module from the python shell of web2py; maybe you'be a clearer traceback.

Unfortunately the traceback above does not help me in understanding the issue. But it seems to be similar to this: https://stackoverflow.com/questions/63123335/distutils-spawn-not-available-unless-imported , maybe you could follow their advices.


Ciao,
Nico

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/b35e69b6-9151-43d3-895a-faf05c03607fn%40googlegroups.com.

Dave S

unread,
May 9, 2022, 8:19:42 PM5/9/22
to web2py-users
On Sunday, May 8, 2022 at 1:55:52 AM UTC-7 nico...@gmail.com wrote:
Hi Dave,

the simplest solution is surely to use web2py from source - and it's even better on py3 if possible.

If you're stick with the frozen app (apart from my simple guide on this at https://github.com/nicozanf/web2py-pyinstaller/blob/master/HOWTO-modules.md), I don't have any special advise - you have to try all the possibilities...
Also, check what happens if you try to import the module from the python shell of web2py; maybe you'be a clearer traceback.

Unfortunately the traceback above does not help me in understanding the issue. But it seems to be similar to this: https://stackoverflow.com/questions/63123335/distutils-spawn-not-available-unless-imported , maybe you could follow their advices.


Ciao,
Nico


Thanks, this gives me something to start looking at, and the fallback of moving to source.  I'll try to report back when I have success.

Dave S
/dps

 
Il giorno sab 7 mag 2022 alle ore 08:00 Massimo Di Pierro <massimo....@gmail.com> ha scritto:
can you try "pip install pillow" instead of putting it in C:\Users\Dave\web2py_win\web2py_win_2.21.1_py27\web2py\site-packages Not all packages like to be there and it can create problems.


On Wednesday, 20 April 2022 at 00:26:48 UTC-7 snide...@gmail.com wrote:
[mumble,mumble]

 
 

Dave S

unread,
May 12, 2022, 6:13:22 PM5/12/22
to web2py-users
On Friday, May 6, 2022 at 11:00:42 PM UTC-7 Massimo Di Pierro wrote:
can you try "pip install pillow" instead of putting it in C:\Users\Dave\web2py_win\web2py_win_2.21.1_py27\web2py\site-packages Not all packages like to be there and it can create problems.


I'm not sure about "can" ...  the package was pip installed into the standalone python, and then copied from that directory's site-packages to the web2py.exe's site-packages.  Does pip work directly in web2py.exe environment, with py.dll?

/dps

Dave S

unread,
May 13, 2022, 2:39:04 AM5/13/22
to web2py-users
On Monday, May 9, 2022 at 5:19:42 PM UTC-7 Dave S wrote:
On Sunday, May 8, 2022 at 1:55:52 AM UTC-7 nico...@gmail.com wrote:
Hi Dave,

the simplest solution is surely to use web2py from source - and it's even better on py3 if possible.

If you're stick with the frozen app (apart from my simple guide on this at https://github.com/nicozanf/web2py-pyinstaller/blob/master/HOWTO-modules.md), I don't have any special advise - you have to try all the possibilities...
Also, check what happens if you try to import the module from the python shell of web2py; maybe you'be a clearer traceback.

Unfortunately the traceback above does not help me in understanding the issue. But it seems to be similar to this: https://stackoverflow.com/questions/63123335/distutils-spawn-not-available-unless-imported , maybe you could follow their advices.


Ciao,
Nico


Thanks, this gives me something to start looking at, and the fallback of moving to source.  I'll try to report back when I have success.

You'll all be relieved to know that Pillow works fine with my installation of Python3 (3.10....), at least for the manipulations I am interested in, and that I can  import it into a web2py shell just fine.  I'll soon be looking at how much 2->3 effort has been hiding behind the curtain, but I think I've got the "print -> print()" part covered.

/dps

Reply all
Reply to author
Forward
0 new messages