使用py2app预期的str,字节或os.PathLike对象而不是NoneType创建可执行文件时出错

问题描述 投票:0回答:1

我正在尝试使用py2app创建可执行文件,但出现此错误,我不确定如何修复它,也不确定是否正确包含了所有文件。

我的工作目录如下:

directory
  -- app_icon.png
  -- app_loading.gif
  -- app_logo.png
  -- detector.pb
  -- model.py
  -- myapp.py
  -- VGG16_weights.h5
  -- VGG16.h5

我的setup.py看起来像这样:

from setuptools import setup

APP = ['myapp.py']
DATA_FILES = ['app_icon.png', 'app_loading.gif', 'app_logo.png', 'VGG16.h5', 'VGG16_weights.h5', 'detector.pb']
OPTIONS = {
    'argv_emulation': True
}

setup(
    app=APP,
    py_modules=['model'],
    data_files=DATA_FILES,
    options={'py2app': OPTIONS},
    setup_requires=["py2app"],
)

[我执行python myapp.py时,我的应用程序可以正常运行,但是在使用]创建可执行文件后,>

python setup.py py2app -A

我跑步时

./dist/myapp.app/Contents/MacOS/myapp

应用程序崩溃,出现以下错误:

Traceback (most recent call last):
  File "/Users/luis/Desktop/py2appexec/dist/myapp.app/Contents/Resources/__boot__.py", line 450, in <module>
    _run()
  File "/Users/luis/Desktop/py2appexec/dist/myapp.app/Contents/Resources/__boot__.py", line 444, in _run
    exec(compile(source, script, "exec"), globals(), globals())
  File "/Users/luis/Desktop/py2appexec/myapp.py", line 3, in <module>
    import model as custom_model
  File "/Users/luis/Desktop/py2appexec/model.py", line 2, in <module>
    import tensorflow as tf
  File "/Users/luis/virtualenvironment/executable/lib/python3.7/site-packages/tensorflow/__init__.py", line 732, in <module>
    plugin_dir = _os.path.join(s, 'tensorflow-plugins')
  File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/posixpath.py", line 80, in join
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType
2020-01-20 11:06:20.690 myapp[3806:164925] myapp Error

似乎在寻找路径时它变得空了,但是我不知道为什么或如何解决它,有什么解决方法吗?

我正在尝试使用py2app创建可执行文件,但出现此错误,我不确定如何修复它,也不确定是否正确包含了所有文件。我的工作目录如下:...

python macos executable py2app
1个回答
0
投票

我有一个类似的问题。 py文件中包含哪些软件包?也许您可以尝试将软件包添加到setup.py文件中。例如,我在OPTIONS变量中有此变量:

© www.soinside.com 2019 - 2024. All rights reserved.