1

I made my py file executable using py2exe. My setup.py is as follows:

from distutils.core import setup
import py2exe

setup(windows=['main.py'])

When I tried to run main.exe, I get an error and was referred to main.log which reads:

Traceback (most recent call last):
  File "main.py", line 20, in <module>
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
  File "C:\Python34\lib\site-packages\pandas\__init__.py", line 7, in <module>
    from . import hashtable, tslib, lib
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
  File "<loader>", line 10, in <module>
  File "<loader>", line 6, in __load
  File "pandas\tslib.pyx", line 2839, in init pandas.tslib (pandas\tslib.c:79846)
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
  File "<loader>", line 10, in <module>
  File "<loader>", line 6, in __load
  File "pandas\algos.pyx", line 64, in init pandas.algos (pandas\algos.c:179610)
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
  File "<loader>", line 10, in <module>
  File "<loader>", line 6, in __load
  File "pandas\lib.pyx", line 1, in init pandas.lib (pandas\lib.c:77889)
AttributeError: 'module' object has no attribute '__pyx_capi__'

It looks like line 20 in my main.py file (import pandas as pd) triggered the problem. This type of error is referenced in a pull request here and they suggested adding a blank __init__.py file. I did so and got same result. I found a well commented post here (not directly dealing with py2exe) that suggests this might be due to mutual top-level imports or circular dependencies. This problem seems well known and has been mentioned at least twice on Stackoverflow in the past year (e.gs: here and here) but no clear solution has been given.

Perhaps we can get more clarity now with your feedback.

Python 3.4.2; py2exe 0.9.2.0

Community
  • 1
  • 1
sedeh
  • 7,083
  • 6
  • 48
  • 65

2 Answers2

0

Was running into the same issue with pandas, but I got it working after updating to the most recent version.

It seems this error was recently addressed, and was resolved in Pandas 15.2 https://github.com/pydata/pandas/issues/8602

0

I was running in the same errors with Python 3.4.4.

My solution was to fix the import statement in C:\Pythob34\lib\site-packagespythoncom.py.

Original: import pywintypes pywintypes.import_pywin32_system_module("pythoncom", globals())

Changed To: from pywintypes import import_pywin32_system_module import_pywin32_system_module("pythoncom", globals())