Flask app上的Pyinstaller,导入错误

时间:2017-12-15 12:20:18

标签: python flask pyinstaller flash-message

我有一个Flask应用程序,包含几个模块,结构如下:

.pears.py
├── app
│   ├── api
│   ├── indexer
│   ├── pod_finder
│   ├── search
│   ├── static
│   └── templates
│       ├── indexer
│       ├── pod_finder
│       └── search

pears.py使用以下命令启动应用程序:

from app import app
app.run(host='0.0.0.0', port=8080, debug=True)

我已经在virtualenv中编写了这个应用程序,因此所有必需的软件包都在env /目录中。

我一直在尝试将此应用与pyinstaller捆绑在一起。创建dist文件夹时没有错误消息,但是当我尝试运行可执行文件时,出现以下错误:

Traceback (most recent call last):
  File "pears.py", line 2, in <module>
    from app import app
ImportError: No module named 'app'
[12110] Failed to execute script pears

即。找不到主模块。我想知道为什么会这样。应用程序中的 init .py文件是否未被pyinstaller注册?我是否需要做任何特定的事情以使其可见?我的spec文件如下。任何帮助将不胜感激。

# -*- mode: python -*-

block_cipher = None

added_files = [
     ( 'app/templates', 'templates' )
    ]

a = Analysis(['pears.spec'],
         pathex=['./env/lib/python3.5/site-packages/', './'],
         binaries=[],
         datas=added_files,
         hiddenimports=[],
         hookspath=[],
         runtime_hooks=[],
         excludes=[],
         win_no_prefer_redirects=False,
         win_private_assemblies=False,
         cipher=block_cipher)

pyz = PYZ(a.pure, a.zipped_data,
         cipher=block_cipher)

exe = EXE(pyz,
      a.scripts,
      exclude_binaries=True,
      name='pears',
      debug=False,
      strip=False,
      upx=True,
      console=True )

coll = COLLECT(exe,
           a.binaries,
           a.zipfiles,
           a.datas,
           strip=False,
           upx=True,
           name='pears')

0 个答案:

没有答案