Okko Willeboordse
2016-11-08 13:38:09 UTC
Hello,
I run in to problems converting a PyQt4/matplotlib application in to a
single executable.
matplotlib does the following;
_decref = ctypes.pythonapi.Py_DecRef
ctypes help; "pythonapi is a predefined symbol giving access to the Python
C api:"
Apparently py2exe loads ctypes such that ctypes.pythonapi is not valid,
since my application fails with;
File "zipextimporter.pyc", line 82, in load_module
File "matplotlib\backends\backend_qt5agg.pyc", line 31, in <module>
File "ctypes\__init__.pyc", line 375, in __getattr__
File "ctypes\__init__.pyc", line 380, in __getitem__
AttributeError: function 'Py_DecRef' not found
I can override ctypes.pythonapi before importing matplotlib as follows;
ctypes.pythonapi = ctypes.PyDLL('python%d%d.dll' % sys.version_info[:2])
With above override things work, however plain wrong since the application
now has 2 interpreters (read python dll's);
one loaded by py2exe and one by the override.
If I could get a handle to the interpreter loaded by py2exe I could do;
ctypes.pythonapi = ctypes.PyDLL(handle_to_py2exe_interpreter)
How to fix ctypes.pythonapi?
Thanks,
Okko Willeboordse
I run in to problems converting a PyQt4/matplotlib application in to a
single executable.
matplotlib does the following;
_decref = ctypes.pythonapi.Py_DecRef
ctypes help; "pythonapi is a predefined symbol giving access to the Python
C api:"
Apparently py2exe loads ctypes such that ctypes.pythonapi is not valid,
since my application fails with;
File "zipextimporter.pyc", line 82, in load_module
File "matplotlib\backends\backend_qt5agg.pyc", line 31, in <module>
File "ctypes\__init__.pyc", line 375, in __getattr__
File "ctypes\__init__.pyc", line 380, in __getitem__
AttributeError: function 'Py_DecRef' not found
I can override ctypes.pythonapi before importing matplotlib as follows;
ctypes.pythonapi = ctypes.PyDLL('python%d%d.dll' % sys.version_info[:2])
With above override things work, however plain wrong since the application
now has 2 interpreters (read python dll's);
one loaded by py2exe and one by the override.
If I could get a handle to the interpreter loaded by py2exe I could do;
ctypes.pythonapi = ctypes.PyDLL(handle_to_py2exe_interpreter)
How to fix ctypes.pythonapi?
Thanks,
Okko Willeboordse