我正在使用py2exe工具生成exe,我正在使用openpyxl库。获取导入错误

时间:2015-04-21 15:59:59

标签: python executable py2exe openpyxl

我正在使用py2exe工具生成exe,我正在使用openpyxl库。 导入错误。

```

  from distutils.core import setup 
   import py2exe 

   setup( 
       console=["Vector.py"], 
       options = { 
        "py2exe":{ 
              "includes":["openpyxl"] 
              }
          } 
       )

```

****错误:****

C:\Users\t7245mh\Desktop\Vector\Script\New files>python Setup.py py2exe
running py2exe
*** searching for required modules ***
Traceback (most recent call last):
  File "Setup.py", line 8, in <module>
    "includes":["openpyxl"]
  File "C:\Python27\lib\distutils\core.py", line 151, in setup
    dist.run_commands()
  File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "C:\Python27\lib\site-packages\py2exe\build_exe.py", line 243, in run
    self._run()
  File "C:\Python27\lib\site-packages\py2exe\build_exe.py", line 296, in _run
    self.find_needed_modules(mf, required_files, required_modules)
  File "C:\Python27\lib\site-packages\py2exe\build_exe.py", line 1297, in find_n
eeded_modules
    mf.import_hook(mod)
  File "C:\Python27\lib\site-packages\py2exe\mf.py", line 719, in import_hook
    return Base.import_hook(self,name,caller,fromlist,level)
  File "C:\Python27\lib\site-packages\py2exe\mf.py", line 136, in import_hook
    q, tail = self.find_head_package(parent, name)
  File "C:\Python27\lib\site-packages\py2exe\mf.py", line 204, in find_head_pack
age
    raise ImportError, "No module named " + qname
ImportError: No module named openpyxl

1 个答案:

答案 0 :(得分:1)

问题:

我安装的openpyxl软件包采用.egg zip格式,py2exe无法识别。

解决方案:

我使用了链接py2exe.org/index.cgi/ExeWithEggs 并使用以下命令重新安装open openpyxl:

easy_install --always-unzip \\Python_Libraries\openpyxl-1.8.6\