Runtime Error on Solaris - Error Closing Dupe File Handle

Good afternoon,

My name is Bryan Williams. I work for the Florida Forest
Service in their Forest Logistics and Support Bureau.

I’m working on a program that takes weather data and
visualizes it using matplotlib and Basemap. I’m currently having an issue with
matplotlib 1.4.3 for Python 3.4.3 running under Solaris 5.10. I am getting a
Runtime Error whenever I try calling the read_png file from matplotlib._png. (I’m
using this to add a small .png file of the Forest Service’s sheld to the
picture). The error is the following:

Traceback
(most recent call last):

File “drawmaps.py”, line 845, in

arr_lena = read_png(fn)

RuntimeError:
Error closing dupe file handle

I don’t quite understand the error I’m getting, and as you
can see, the traceback gives very little information. I also tried Google for
help, but to no avail; entering the error message as is into Google doesn’t
return anything relating to the problem, and putting quotes around “Error
closing dupe file handle” yields about 10 results, with one of them being an
unanswered question from 2014 regarding the same issue.

As per your request on the website, here’s what I get from
uname –a:

SunOS [server name withheld] 5.10
Generic_141444-09 sun4v sparc SUNW,SPARC-Enterprise-T5220

I built Python 3.4.3 from source and installed matplotlib
through pip, and didn’t make any changes to the matplotlibrc file.

I was able to reproduce the problem again running these
commands in the Python interactive prompt, which emulates the snippet of script
that causes the error:

Python
3.4.3 (default, May 15 2015, 13:52:23)

[GCC
4.9.2] on sunos5

Type
“help”, “copyright”, “credits” or
“license” for more information.

from matplotlib._png import read_png

from matplotlib.cbook import get_sample_data

import os; path=os.getcwd()

fn = get_sample_data(path + ‘/resources/shield.png’, asfileobj=False)

arr_lena = read_png(fn)

Traceback
(most recent call last):

File “”, line 1, in

RuntimeError:
Error closing dupe file handle

If you’d like a copy of the problem script, please let me
know. Any and all help is greatly appreciated.

Thank you in advance!

– BMW

Bryan,

First off, avoid importing things from modules that start with an underscore. Because Python doesn’t have semantics for public/private APIs like C++ and Java does, the underscore is treated as an indicator to developers that it is to be treated as private. The implication is that we are free to change the API of “private” modules and functions between releases, without warning or recourse, which would lead to breakage of your scripts if you use them. So, use it at your peril.

I would recommend using plt.imread() instead, or use the Pillow package to read your data as a numpy array that you can then plot.

Now, onto your issue. I suspect it might be related to changes we made in 1.4 to have a cross-platform file-handle. However, the solaris platform is not regularly tested by anybody, so it is quite likely we broke something there. Now, in the master branch on github, we completely rewrote nearly all of the C++ code, so I while it may still be broken there, perhaps we might get a more useful error message or something different entirely? Can you try building from the master branch and letting us know?

Cheers!

Ben Root

P.S. - The script in question wasn’t perhaps written originally by a former Meteorologist colleague from the University of Oklahoma? :wink: If it was, he was my officemate!

···

On Thu, May 21, 2015 at 4:08 PM, Bryan Williams <bryan.williams7889@…287…> wrote:

Good afternoon,

My name is Bryan Williams. I work for the Florida Forest
Service in their Forest Logistics and Support Bureau.

I’m working on a program that takes weather data and
visualizes it using matplotlib and Basemap. I’m currently having an issue with
matplotlib 1.4.3 for Python 3.4.3 running under Solaris 5.10. I am getting a
Runtime Error whenever I try calling the read_png file from matplotlib._png. (I’m
using this to add a small .png file of the Forest Service’s sheld to the
picture). The error is the following:

Traceback
(most recent call last):

File “drawmaps.py”, line 845, in

arr_lena = read_png(fn)

RuntimeError:
Error closing dupe file handle

I don’t quite understand the error I’m getting, and as you
can see, the traceback gives very little information. I also tried Google for
help, but to no avail; entering the error message as is into Google doesn’t
return anything relating to the problem, and putting quotes around “Error
closing dupe file handle” yields about 10 results, with one of them being an
unanswered question from 2014 regarding the same issue.

As per your request on the website, here’s what I get from
uname –a:

SunOS [server name withheld] 5.10
Generic_141444-09 sun4v sparc SUNW,SPARC-Enterprise-T5220

I built Python 3.4.3 from source and installed matplotlib
through pip, and didn’t make any changes to the matplotlibrc file.

I was able to reproduce the problem again running these
commands in the Python interactive prompt, which emulates the snippet of script
that causes the error:

Python
3.4.3 (default, May 15 2015, 13:52:23)

[GCC
4.9.2] on sunos5

Type
“help”, “copyright”, “credits” or
“license” for more information.

from matplotlib._png import read_png

from matplotlib.cbook import get_sample_data

import os; path=os.getcwd()

fn = get_sample_data(path + ‘/resources/shield.png’, asfileobj=False)

arr_lena = read_png(fn)

Traceback
(most recent call last):

File “”, line 1, in

RuntimeError:
Error closing dupe file handle

If you’d like a copy of the problem script, please let me
know. Any and all help is greatly appreciated.

Thank you in advance!

– BMW


One dashboard for servers and applications across Physical-Virtual-Cloud

Widest out-of-the-box monitoring support with 50+ applications

Performance metrics, stats and reports that give you Actionable Insights

Deep dive visibility with transaction tracing using APM Insight.

http://ad.doubleclick.net/ddm/clk/290420510;117567292;y


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Bryan,

If you subscribe to the list you will be able to post with out moderation.

Does this happen with any of the other sample data?

I don’t think that get_sample_data is doing you any good here as you are passing it an absolute path (from os.getcwd()) which is passed into os.path.join which when it encounters and absolute path discards everything to the left so that line is just returning back your input.

Does it work to open any other png or does only this png have issues?

You are reaching into the nominally private parts of the mpl api here, I would suggest using mpl.image.imread instead.

It might be worth using something like PIL/pillow, imread (https://pypi.python.org/pypi/imread), imageio (https://imageio.github.io/) or scikit-image for alternate implementations of png readers.

None of the core developers have access to a Solaris machine so it is very difficult for us to provide much better help on this.

Tom

···

On Sun, May 24, 2015 at 1:38 PM Bryan Williams <bryan.williams7889@…287…> wrote:

Good afternoon,

My name is Bryan Williams. I work for the Florida Forest
Service in their Forest Logistics and Support Bureau.

I’m working on a program that takes weather data and
visualizes it using matplotlib and Basemap. I’m currently having an issue with
matplotlib 1.4.3 for Python 3.4.3 running under Solaris 5.10. I am getting a
Runtime Error whenever I try calling the read_png file from matplotlib._png. (I’m
using this to add a small .png file of the Forest Service’s sheld to the
picture). The error is the following:

Traceback
(most recent call last):

File “drawmaps.py”, line 845, in

arr_lena = read_png(fn)

RuntimeError:
Error closing dupe file handle

I don’t quite understand the error I’m getting, and as you
can see, the traceback gives very little information. I also tried Google for
help, but to no avail; entering the error message as is into Google doesn’t
return anything relating to the problem, and putting quotes around “Error
closing dupe file handle” yields about 10 results, with one of them being an
unanswered question from 2014 regarding the same issue.

As per your request on the website, here’s what I get from
uname –a:

SunOS [server name withheld] 5.10
Generic_141444-09 sun4v sparc SUNW,SPARC-Enterprise-T5220

I built Python 3.4.3 from source and installed matplotlib
through pip, and didn’t make any changes to the matplotlibrc file.

I was able to reproduce the problem again running these
commands in the Python interactive prompt, which emulates the snippet of script
that causes the error:

Python
3.4.3 (default, May 15 2015, 13:52:23)

[GCC
4.9.2] on sunos5

Type
“help”, “copyright”, “credits” or
“license” for more information.

from matplotlib._png import read_png

from matplotlib.cbook import get_sample_data

import os; path=os.getcwd()

fn = get_sample_data(path + ‘/resources/shield.png’, asfileobj=False)

arr_lena = read_png(fn)

Traceback
(most recent call last):

File “”, line 1, in

RuntimeError:
Error closing dupe file handle

If you’d like a copy of the problem script, please let me
know. Any and all help is greatly appreciated.

Thank you in advance!

– BMW


One dashboard for servers and applications across Physical-Virtual-Cloud

Widest out-of-the-box monitoring support with 50+ applications

Performance metrics, stats and reports that give you Actionable Insights

Deep dive visibility with transaction tracing using APM Insight.

http://ad.doubleclick.net/ddm/clk/290420510;117567292;y_______________________________________________

Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Thanks to the both of you.

First off, apologies for getting back to you several days late. I was out of town for the holiday weekend, and I didn’t get a chance to work on this for the last two days as I had other business to tend to on Tuesday, and was out of the office all day Wednesday.

I tried to install from the master build on Github, and it seemed to run fine, until I ended up with this error (and verbose details, text wall incoming):

···

On Sun, May 24, 2015 at 2:05 PM, Thomas Caswell <tcaswell@…287…> wrote:

Bryan,

If you subscribe to the list you will be able to post with out moderation.

Does this happen with any of the other sample data?

I don’t think that get_sample_data is doing you any good here as you are passing it an absolute path (from os.getcwd()) which is passed into os.path.join which when it encounters and absolute path discards everything to the left so that line is just returning back your input.

Does it work to open any other png or does only this png have issues?

You are reaching into the nominally private parts of the mpl api here, I would suggest using mpl.image.imread instead.

It might be worth using something like PIL/pillow, imread (https://pypi.python.org/pypi/imread), imageio (https://imageio.github.io/) or scikit-image for alternate implementations of png readers.

None of the core developers have access to a Solaris machine so it is very difficult for us to provide much better help on this.

Tom

On Sun, May 24, 2015 at 1:38 PM Bryan Williams <bryan.williams7889@…287…> wrote:

Good afternoon,

My name is Bryan Williams. I work for the Florida Forest
Service in their Forest Logistics and Support Bureau.

I’m working on a program that takes weather data and
visualizes it using matplotlib and Basemap. I’m currently having an issue with
matplotlib 1.4.3 for Python 3.4.3 running under Solaris 5.10. I am getting a
Runtime Error whenever I try calling the read_png file from matplotlib._png. (I’m
using this to add a small .png file of the Forest Service’s sheld to the
picture). The error is the following:

Traceback
(most recent call last):

File “drawmaps.py”, line 845, in

arr_lena = read_png(fn)

RuntimeError:
Error closing dupe file handle

I don’t quite understand the error I’m getting, and as you
can see, the traceback gives very little information. I also tried Google for
help, but to no avail; entering the error message as is into Google doesn’t
return anything relating to the problem, and putting quotes around “Error
closing dupe file handle” yields about 10 results, with one of them being an
unanswered question from 2014 regarding the same issue.

As per your request on the website, here’s what I get from
uname –a:

SunOS [server name withheld] 5.10
Generic_141444-09 sun4v sparc SUNW,SPARC-Enterprise-T5220

I built Python 3.4.3 from source and installed matplotlib
through pip, and didn’t make any changes to the matplotlibrc file.

I was able to reproduce the problem again running these
commands in the Python interactive prompt, which emulates the snippet of script
that causes the error:

Python
3.4.3 (default, May 15 2015, 13:52:23)

[GCC
4.9.2] on sunos5

Type
“help”, “copyright”, “credits” or
“license” for more information.

from matplotlib._png import read_png

from matplotlib.cbook import get_sample_data

import os; path=os.getcwd()

fn = get_sample_data(path + ‘/resources/shield.png’, asfileobj=False)

arr_lena = read_png(fn)

Traceback
(most recent call last):

File “”, line 1, in

RuntimeError:
Error closing dupe file handle

If you’d like a copy of the problem script, please let me
know. Any and all help is greatly appreciated.

Thank you in advance!

– BMW


One dashboard for servers and applications across Physical-Virtual-Cloud

Widest out-of-the-box monitoring support with 50+ applications

Performance metrics, stats and reports that give you Actionable Insights

Deep dive visibility with transaction tracing using APM Insight.

http://ad.doubleclick.net/ddm/clk/290420510;117567292;y_______________________________________________

Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

I think there is on open bug about compilation failures on Solaris which we never sorted out due to not having access to a test machine.

···

On Sun, May 24, 2015 at 2:05 PM, Thomas Caswell <tcaswell@…287…> wrote:

Bryan,

If you subscribe to the list you will be able to post with out moderation.

Does this happen with any of the other sample data?

I don’t think that get_sample_data is doing you any good here as you are passing it an absolute path (from os.getcwd()) which is passed into os.path.join which when it encounters and absolute path discards everything to the left so that line is just returning back your input.

Does it work to open any other png or does only this png have issues?

You are reaching into the nominally private parts of the mpl api here, I would suggest using mpl.image.imread instead.

It might be worth using something like PIL/pillow, imread (https://pypi.python.org/pypi/imread), imageio (https://imageio.github.io/) or scikit-image for alternate implementations of png readers.

None of the core developers have access to a Solaris machine so it is very difficult for us to provide much better help on this.

Tom

On Sun, May 24, 2015 at 1:38 PM Bryan Williams <bryan.williams7889@…83…287…> wrote:

Good afternoon,

My name is Bryan Williams. I work for the Florida Forest
Service in their Forest Logistics and Support Bureau.

I’m working on a program that takes weather data and
visualizes it using matplotlib and Basemap. I’m currently having an issue with
matplotlib 1.4.3 for Python 3.4.3 running under Solaris 5.10. I am getting a
Runtime Error whenever I try calling the read_png file from matplotlib._png. (I’m
using this to add a small .png file of the Forest Service’s sheld to the
picture). The error is the following:

Traceback
(most recent call last):

File “drawmaps.py”, line 845, in

arr_lena = read_png(fn)

RuntimeError:
Error closing dupe file handle

I don’t quite understand the error I’m getting, and as you
can see, the traceback gives very little information. I also tried Google for
help, but to no avail; entering the error message as is into Google doesn’t
return anything relating to the problem, and putting quotes around “Error
closing dupe file handle” yields about 10 results, with one of them being an
unanswered question from 2014 regarding the same issue.

As per your request on the website, here’s what I get from
uname –a:

SunOS [server name withheld] 5.10
Generic_141444-09 sun4v sparc SUNW,SPARC-Enterprise-T5220

I built Python 3.4.3 from source and installed matplotlib
through pip, and didn’t make any changes to the matplotlibrc file.

I was able to reproduce the problem again running these
commands in the Python interactive prompt, which emulates the snippet of script
that causes the error:

Python
3.4.3 (default, May 15 2015, 13:52:23)

[GCC
4.9.2] on sunos5

Type
“help”, “copyright”, “credits” or
“license” for more information.

from matplotlib._png import read_png

from matplotlib.cbook import get_sample_data

import os; path=os.getcwd()

fn = get_sample_data(path + ‘/resources/shield.png’, asfileobj=False)

arr_lena = read_png(fn)

Traceback
(most recent call last):

File “”, line 1, in

RuntimeError:
Error closing dupe file handle

If you’d like a copy of the problem script, please let me
know. Any and all help is greatly appreciated.

Thank you in advance!

– BMW


One dashboard for servers and applications across Physical-Virtual-Cloud

Widest out-of-the-box monitoring support with 50+ applications

Performance metrics, stats and reports that give you Actionable Insights

Deep dive visibility with transaction tracing using APM Insight.

http://ad.doubleclick.net/ddm/clk/290420510;117567292;y_______________________________________________

Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Maybe you can do this with an environment variable?

export CC=/usr/bin/cc

It does look like there is a problem with scrambled environments. The redefinition warning looks potentially troublesome; and the error looks like a conflict between two versions of the standard C library.

From "man swab" on Solaris:

NAME
      swab - swap bytes

SYNOPSIS
      #include <stdlib.h>

      void swab(const char *src, char *dest, ssize_t nbytes);

   XPG4, SUS, SUSv2, SUSv3
      #include <unistd.h>

      void swab(const void *restrict src, void *restrict dest,
      ssize_t nbytes);

I think you want the second version, consistently, but something is also hitting the first version.

Maybe "XPG4" or one of the other 4 options needs to be defined when each library is compiled with /usr/bin/cc? I think the stdlib declaration is old; the unistd version is more modern.

That's all very vague, I know. Obviously, I don't actually know how to solve the problem.

Eric

···

On 2015/05/28 3:13 AM, Bryan Williams wrote:

I have gcc on the box. I also installed the C compiler for Solaris (cc),
but I couldn't seem to find an option to switch it so that it uses cc
rather than gcc.

It seems like it is a conflict of libraries…I’ve zeroed in to these two errors:

/usr/include/unistd.h:496:75: error: conflicting declaration of C function ‘void swab(const void*, void*, ssize_t)’

and

/usr/include/stdlib.h:144:13: note: previous declaration ‘void swab(const char*, char*, ssize_t)’

I executed a find command and here’s what came up:
~>sudo find / -name stdlib.h
/opt/csw/include/c++/4.9.2/tr1/stdlib.h
/opt/solarisstudio12.4/lib/compilers/include/CC/gnu/stdlib.h
/opt/solarisstudio12.4/lib/compilers/include/CC/stlport4/stdlib.h
/opt/solarisstudio12.4/lib/compilers/CC-gcc/include/c++/4.8.2/tr1/stdlib.h
/usr/include/stdlib.h

From what it seems, it’s calling stdlib.h from the /usr/include folder when it should be calling it from /opt/csw/include. I’m going to look into setup.cfg (that or perhaps hack setup.py) and see if it’s at all possible to change it so that it looks in the right one, and then I’ll try building it again.

···

On Thu, May 28, 2015 at 1:50 PM, Eric Firing <efiring@…202…> wrote:

On 2015/05/28 3:13 AM, Bryan Williams wrote:

I have gcc on the box. I also installed the C compiler for Solaris (cc),

but I couldn’t seem to find an option to switch it so that it uses cc

rather than gcc.

Maybe you can do this with an environment variable?

export CC=/usr/bin/cc

It does look like there is a problem with scrambled environments. The

redefinition warning looks potentially troublesome; and the error looks

like a conflict between two versions of the standard C library.

From “man swab” on Solaris:

NAME

  swab - swap bytes

SYNOPSIS

  #include <stdlib.h>



  void swab(const char *src, char *dest, ssize_t nbytes);

XPG4, SUS, SUSv2, SUSv3

  #include <unistd.h>



  void swab(const void *restrict  src,  void  *restrict  dest,

  ssize_t nbytes);

I think you want the second version, consistently, but something is also

hitting the first version.

Maybe “XPG4” or one of the other 4 options needs to be defined when each

library is compiled with /usr/bin/cc? I think the stdlib declaration is

old; the unistd version is more modern.

That’s all very vague, I know. Obviously, I don’t actually know how to

solve the problem.

Eric



Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users