使用cx_Freeze冻结pandas/NumPy 1.7.0代码时出错 [英] Error when freezing pandas/NumPy 1.7.0 code with cx_Freeze

查看:86
本文介绍了使用cx_Freeze冻结pandas/NumPy 1.7.0代码时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用cx_Freeze冻结Python脚本.该脚本使用了熊猫.运行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)

当我尝试在cx_Freeze设置文件的'packages'下包含'pandas'时,它在冻结过程中失败,显示以下内容:

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  

对于Windows7(64位)上的Python 2.7.3的32位和64位版本,我也遇到了同样的问题.熊猫版本为0.10.1,cx_Freeze为4.3.1.

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.

你们中的任何熊猫或cx_Freeze神灵都有主意吗?

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

推荐答案

我刚刚查看了/numpy/core/init.py,并注意到了倒数第二行:

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

有"del sys"

there is "del sys"

如果您对此行注释掉,它将按预期工作.我还注意到numpy 1.6.2中没有"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

您可以尝试与numpy联系以检查他们为什么需要这样做.

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

这篇关于使用cx_Freeze冻结pandas/NumPy 1.7.0代码时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆