Error when freezing pandas/NumPy 1.7.0 code with cx_Freeze

巧了我就是萌 提交于 2019-12-11 03:51:35

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/14969552/error-when-freezing-pandas-numpy-1-7-0-code-with-cx-freeze

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!