Problem loading PNG images under Cygwin

113 views
Skip to first unread message

matt

unread,
Jun 14, 2012, 8:31:14 PM6/14/12
to wxpytho...@googlegroups.com
Hi, I build wx 2.8.11.0 under current Cygwin Here is screenshot of Matplotlib plot (with wxagg backend) showing my issue: http://i.stack.imgur.com/Fsstp.png As I had no idea which issue is this, I run sample code under Winpdb and couldn't see any exception from Matplotlib, suggesting that it's not MPL issue. Then I downloaded SPE - it couldn't start because of this same error - somehow wx couldn't load PNG file, although it's there. I tried also other wx application - Pype editor, and again same error is thrown, although program runs fine unless it wants to access image resource and pops error dialog Why can this be, and is there any simple way to remedy this without having to remove wx or trying similar approaches Thanks

View this message in context: Problem loading PNG images under Cygwin
Sent from the wxPython-users mailing list archive at Nabble.com.

Robin Dunn

unread,
Jun 14, 2012, 11:34:56 PM6/14/12
to wxpytho...@googlegroups.com
On 6/14/12 5:31 PM, matt wrote:
> Hi, I build wx 2.8.11.0 under current Cygwin Here is screenshot of
> Matplotlib plot (with wxagg backend) showing my issue:
> http://i.stack.imgur.com/Fsstp.png As I had no idea which issue is this,
> I run sample code under Winpdb and couldn't see any exception from
> Matplotlib, suggesting that it's not MPL issue. Then I downloaded SPE -
> it couldn't start because of this same error - somehow wx couldn't load
> PNG file, although it's there. I tried also other wx application - Pype
> editor, and again same error is thrown, although program runs fine
> unless it wants to access image resource and pops error dialog Why can
> this be, and is there any simple way to remedy this without having to
> remove wx or trying similar approaches Thanks

I don't even know if it is possible but the only thing that comes to
mind for me is that perhaps wxWidgets was built as a mingw32 lib instead
of a cygwin lib, and if that is the case then those path names are not
valid DOS/Windows paths.


--
Robin Dunn
Software Craftsman
http://wxPython.org

Gadget/Steve

unread,
Jun 15, 2012, 1:02:18 AM6/15/12
to wxpytho...@googlegroups.com
Your debug output clearly shows that you are trying to load the file from /usr/lib but the terminal in the background shows that the files exist under /lib this suggests that you are using a relative path or one generated from the environment variables and that you environment variables are different between Winpdb to those under SPE, Pype, etc.  Do you by any chance have more than one copy of python 2.6 installed with mpl only installed on one of them?

Gadget/Steve

matt...@mac.hush.com

unread,
Jun 15, 2012, 7:10:46 AM6/15/12
to wxpytho...@googlegroups.com
> Your debug output clearly shows that you are trying to load the file from
> /usr/lib but the terminal in the background shows that the files exist under
> /lib this suggests that you are using a relative path or one generated from
> the environment variables and that you environment variables are different
> between Winpdb to those under SPE, Pype, etc. Do you by any chance have more
> than one copy of python 2.6 installed with mpl only installed on one of them?

Yes, the problem seem to be path related.

Root Cygwin folder is in "C:\cygwin".
In Cygwin shell there are two identical folders:

/lib/

and

/usr/lib/

with same content, so one is just link or other through some Cygwin instrument. "ls" doesn't show any info about symbolic link or similar, but if I open Explorer I can't see "/usr/lib/" folder but just /lib/. Perhaps similarly wx can't see it.

Any ideas how to approach this or should I post in Cygwin mailing list instead?

Thanks

Steve Barnes

unread,
Jun 15, 2012, 7:42:33 AM6/15/12
to wxpytho...@googlegroups.com
You could use try, except to try loading from one path with the other as a fallback or only use local images.

-----Original Message-----
--
To unsubscribe, send email to wxPython-user...@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

matt...@mac.hush.com

unread,
Jun 15, 2012, 8:43:00 AM6/15/12
to wxpytho...@googlegroups.com
Here is another interesting screenshot: http://i.imgur.com/ANu0r.png



Also loading files from"/usr/lib/" with any other python package is without issue

matt...@mac.hush.com

unread,
Jun 15, 2012, 10:49:13 AM6/15/12
to wxpytho...@googlegroups.com
Hm, not just that, but it can't read also from "/lib/":

========================================
$ python
Python 2.6.8 (unknown, Jun 9 2012, 11:30:32)
[GCC 4.5.3] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
>>> wx.Image.CanRead('/usr/lib/python2.6/site-packages/matplotlib/mpl-data/images/filesave.png')
True
>>> wximg = wx.Image('/usr/lib/python2.6/site-packages/matplotlib/mpl-data/images/filesave.png', wx.BITMAP_TYPE_ANY)
16:31:33: Error: Can't load image from file '/usr/lib/python2.6/site-packages/matplotlib/mpl-data/images/filesave.png': file does not exist.
>>> wximg = wx.Image('/lib/python2.6/site-packages/matplotlib/mpl-data/images/filesave.png', wx.BITMAP_TYPE_ANY)
16:31:38: Error: Can't load image from file '/lib/python2.6/site-packages/matplotlib/mpl-data/images/filesave.png': file does not exist.
========================================

matt...@mac.hush.com

unread,
Jun 15, 2012, 1:10:28 PM6/15/12
to wxpytho...@googlegroups.com
OK, as I can't figure what's wrong, can someone be kind and suggest which file should I patch and how, to be able to use wx without errors?

This seem to work:
====================
f = open('/path-to/file', 'rb')
wx.ImageFromStream(f,...)
f.close()
====================

I suspect that file _core.py in wx folder in Python site-packages should be changed somehow so that it can read posix path pass to it through python file handle.
Or maybe somehow else

Robin Dunn

unread,
Jun 15, 2012, 2:37:12 PM6/15/12
to wxpytho...@googlegroups.com
The code that is attempting to open the image file and read it is in the
wxWidgets C++ code, in wxImage. As I understand it, if wxWidgets was
properly built in cygwin mode then it should be able to read it with no
problem just like on a true unix, but I've never done such a build
myself so I can't really help with it, other than taking shots in the
dark.

You should try asking about this on the wx-users mail list, and give
details about how your wxWidgets was built or where it came from if you
installed a pre-built binary. It would also be a good idea to check and
see if you can duplicate this problem in a C++ sample, such as the
wxWidgets/samples/image demo program.

matt...@mac.hush.com

unread,
Jun 15, 2012, 2:47:22 PM6/15/12
to wxpytho...@googlegroups.com
> The code that is attempting to open the image file and read it is in the
> wxWidgets C++ code, in wxImage. As I understand it, if wxWidgets was
> properly built in cygwin mode then it should be able to read it with no
> problem just like on a true unix, but I've never done such a build
> myself so I can't really help with it, other than taking shots in the
> dark.
>
> You should try asking about this on the wx-users mail list, and give
> details about how your wxWidgets was built or where it came from if you
> installed a pre-built binary. It would also be a good idea to check and
> see if you can duplicate this problem in a C++ sample, such as the
> wxWidgets/samples/image demo program.

I think you are right. Probably I compiled wx on Cygwin for Windows instead for Cygwin, so it can't read Cygwin POSIX paths
I'll try some wx Cygwin port and remove my compile

Thanks for everyone's time
Cheers

Reply all
Reply to author
Forward
0 new messages