如何使用cx_freeze或py2exe,xlwings,numpy

时间:2015-10-22 16:06:37

标签: python numpy py2exe cx-freeze xlwings

我正在使用xlwings,当我想通过freezed脚本运行我的cx_Freeze时,我有以下错误:

Traceback (most recent call last):
  File "C:\Users\D\Anaconda\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27, in <module>
    exec(code, m.__dict__)
  File "prueba.py", line 1, in <module>
  File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 2237, in _find_and_load
  File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 2226, in _find_and_load_unlocked
  File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 1191, in _load_unlocked
  File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 1161, in _load_backward_compatible
  File "C:\Users\D\Anaconda\lib\site-packages\numpy\__init__.py", line 206, in <module>
    from . import ma
  File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 2284, in _handle_fromlist
  File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 321, in _call_with_frames_removed
  File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 2237, in _find_and_load
  File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 2226, in _find_and_load_unlocked
  File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 1191, in _load_unlocked
  File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 1161, in _load_backward_compatible
  File "C:\Users\D\Anaconda\lib\site-packages\numpy\ma\__init__.py", line 49, in <module>
    from . import extras
  File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 2284, in _handle_fromlist
  File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 321, in _call_with_frames_removed
  File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 2237, in _find_and_load
  File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 2226, in _find_and_load_unlocked
  File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 1191, in _load_unlocked
  File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 1161, in _load_backward_compatible
  File "C:\Users\D\Anaconda\lib\site-packages\numpy\ma\extras.py", line 438, in <module>
    :np.apply_over_axes.__doc__.find('Notes')].rstrip() + \
AttributeError: 'NoneType' object has no attribute 'find'

我的setup.py文件如下所示:

from cx_Freeze import setup, Executable
build_exe_options = {'packages': ['win32com', 'xlwings'],
                     'optimize': 2}
setup(name = 'prueba',
      version = '0.1.0',
      options = {'build_exe': build_exe_options},
      executables = [Executable('prueba.py')])

我已经读过numpy&amp; cx_Frezze的问题,所以我也试图用py2exe冻结python到exe。

这里还有另一个问题......当我想在excel中运行时,没有任何响应,也没有任何变化。

1 个答案:

答案 0 :(得分:1)

我可以使用python3成功地使用以下xlwings cx_freeze setup.py

from cx_Freeze import setup, Executable

buildOptions = dict(packages = [], excludes = [])

base = 'Console'

executables = [
    Executable('main.py', base=base, targetName = 'main.exe')
]

setup(name='foo',
      version = '0.1',
      description = 'bar',
      options = dict(build_exe = buildOptions),
      executables = executables)
  

这里还有另一个问题......当我想在excel中运行时,没有任何响应,也没有任何变化。

你的意思是代码在冻结之前不起作用吗?