简体   繁体   中英

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?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM