Felix Zumstein
Felix Zumstein

Reputation: 7070

Error when freezing pandas/NumPy 1.7.0 code with cx_Freeze

I am trying to freeze a Python script with cx_Freeze. The script makes use of pandas. When I run the executable created by cx_Freeze, I get the following Traceback:

[...]  
File "C:\Python27\lib\site-packages\pandas\__init__.py", line 6, in <module>  
from . import hashtable, tslib, lib  
File "ExtensionLoader_pandas_hashtable.py", line 11, in <module>  
File "numpy.pxd", line 156, in init pandas.hashtable (pandas\hashtable.c:20273)  
File "C:\Python27\lib\site-packages\numpy\__init__.py", line 147, in <module>  
from core import *  
AttributeError: 'module' object has no attribute 'sys'

The only pandas code I am using (for testing) is:

from pandas import DataFrame
import pandas as pd
d = {'one' : [1., 2., 3., 4.],
     'two' : [4., 3., 2., 1.]}
df = DataFrame(d)

When I try to include 'pandas' under 'packages' in the cx_Freeze setup file, it fails during the freeze process with:

ValueError: too many values to unpack  

I have encountered this same issue for 32 and 64 bit versions of Python 2.7.3 on Windows7 (64bit). pandas version is 0.10.1 and cx_Freeze is 4.3.1.

Does anybody of you pandas or cx_Freeze gods have an idea?

Upvotes: 2

Views: 3177

Answers (2)

dynamicgl
dynamicgl

Reputation: 66

I just looked at the /numpy/core/init.py and noticed at the second last line:

there is "del sys"

if you comment out this line, it works as expected. I also noticed there was no "del sys" in numpy 1.6.2

you may try to contact numpy to check why they need to do this.

Upvotes: 5

Felix Zumstein
Felix Zumstein

Reputation: 7070

The reason for both errors seem to be NumPy 1.7.0 (pandas builds on NumPy). When I run the code with NumPy 1.6.2, everything works.

Upvotes: 0

Related Questions