2013-08-29 62 views
0

我已經基於this example這個代碼:pyTables py2exe例如不運行

from tables import * 

class Particle(IsDescription): 
    name = StringCol(16) # 16-character String 
    idnumber = Int64Col() # Signed 64-bit integer 
    ADCcount = UInt16Col() # Unsigned short integer 
    TDCcount = UInt8Col() # Unsigned byte 
    grid_i = Int32Col() # Integer 
    grid_j = IntCol() # Integer (equivalent to Int32Col) 
    pressure = Float32Col() # Float (single-precision) 
    energy = FloatCol() # Double (double-precision) 

h5file = openFile("tutorial.h5", mode="w", title="Test file") 
group = h5file.createGroup("/", "detector", "Detector information") 
table = h5file.createTable(group, "readout", Particle, "Readout example") 

print h5file 

particle = table.row 

for i in xrange(10): 
    particle['name'] = 'Particle: %6d' % i 
    particle['TDCcount'] = i % 256 
    particle['ADCcount'] = (i*256) % (1<<16) 
    particle['grid_i'] = i 
    particle['grid_j'] = 10 - i 
    particle['pressure'] = float(i*i) 
    particle['energy'] = float(particle['pressure']**4) 
    particle['idnumber'] = i * (2**34) 
    particle.append() 

table.flush() 

table = h5file.root.detector.readout 
pressure = [x['pressure'] for x in table.iterrows() if x['TDCcount']>3 and 
                 20<=x['pressure']<50] 

print pressure 

h5file.close() 

而且我與py2exe具有以下setup.py文件編譯它:

import os 
import shutil 

print '*\n*\nBegin clean up...\n*\n*' 

build_folder_name = 'build' 
dist_folder_name = 'dist' 

build_path = os.path.abspath(os.path.join(os.curdir, build_folder_name)) 
if os.path.exists(build_path): 
    print 'removing folder: {0}'.format(build_path) 
    shutil.rmtree(build_path) 

dist_path = os.path.abspath(os.path.join(os.curdir, dist_folder_name)) 
if os.path.exists(dist_path): 
    print 'removing folder: {0}'.format(dist_path) 
    shutil.rmtree(dist_path) 

print '*\n*\nClean up done. Setup will now begin...\n*\n*' 

from distutils.core import setup 
import py2exe 

import numpy # http://stackoverflow.com/questions/15478230/pack-a-software-in-python-using-py2exe-with-libiomp5md-dll-not-found 

excludes_list = [] 

includes_list = [ 
    'numpy', 
    'tables', 
    'tables.utilsextension' 
] 

setup(
    console=['run_me.py'] 
    , options={ 
     'py2exe': { 
      'excludes': excludes_list 
      , 'includes': includes_list 
      , 'dll_excludes': ['w9xpopen.exe', 'MSVCP90.dll', 'libzmq.dll'] 
     } 
    } 
) 

生成的可執行文件呢不運行,併產生此錯誤:

Traceback (most recent call last): 
    File "run_me.py", line 1, in <module> 
    File "tables\__init__.pyc", line 82, in <module> 
    File "tables\utilsextension.pyc", line 12, in <module> 
    File "tables\utilsextension.pyc", line 10, in __load 
    File "utilsextension.pyx", line 275, in init tables.utilsextension (tables\utilsextension.c:15283) 
ImportError: No module named _comp_lzo 

我想了解爲什麼會發生此錯誤,以及如何 要解決這個問題。任何指針將不勝感激。

我的環境是Win7和Python 2.7.3。其他的包是通過PIP或從Unofficial Windows Binaries

+0

任何運氣這個問題? – codeKiller

+0

沒有運氣。我們停止將pyTables包含在構建中,並通過解決方法解決了問題。我本來希望PyTables的人會提供支持。 – Pablo

回答

0

加入「tables._comp_lzo」到includes_list安裝解決了對那些有問題