Question

import numpy

When I packaged above one line script as a single executable window application using py2exe, I get following warnings upon launch.

OMP: Warning #178: Function GetModuleHandleEx failed:
OMP: System error #126: The specified module could not be found.

This warning happen only when I build as single executable (i.e., only when bundle_files=1). Here's my setup.py for this.

from distutils.core import setup
import py2exe

setup(
    options = {'py2exe': {'bundle_files': 1}},
    windows=['testnumpy.py'],
    zipfile = None,
)

This problem started with numpy 1.8.0. When I revert back to 1.6.2, the warnings don't show up.

Usually a single executable packaged by py2exe will catch warnings and traceback and save them into a log file. But somehow these warnings are not captured and the app creates a console window to show warning. I want to suppress this additional console window to show up.

How can I fix this warning problem?

What I tried (nothing worked):

  1. I tried this redirecting sys.stderr.
  2. I searched github numpy source for openMP assuming the OMP stands for it as mentioned here. But, nothing useful came out.
  3. I have copied libiomp5md.dll to the same folder as setup.py.
  4. I tried filterwarnings:
  5. I tried sys.excepthook.
Was it helpful?

Solution

As I wrote in the comment, installing numpy 1.8.1rc1 from sourceforge did fix the issue, although I don't really know the differences...

OTHER TIPS

I had this issue with numpy 1.13.1+mkl and scipy 1.19.1. Reverting to numpy 1.8.1rc1 is not an acceptable solution.

I tracked this issue to the scipy.integrate subpackage. The warning message pops up when this package is imported. It seems that perhaps libraries that use MKL don't like being invoked from library.zip, which is where py2exe places packages when using bundle option 2.

The solution is to exclude scipy and numpy in the py2exe setup script and copy their entire package folders into the distribution directory and add that directory to the system path at the top of the main python script.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top