python - 使用 py2app 预期的 str、字节或 os.PathLike 对象创建可执行文件时出错,而不是 NoneType
问题描述
我正在尝试使用 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
在寻找路径时似乎它变得空,但我不知道为什么或如何修复它,有什么解决方案吗?
解决方案
我有一个类似的问题。py
您的文件中有哪些软件包?也许您可以尝试将包添加到您的setup.py
文件中。例如,我的OPTIONS
变量中有这个:
OPTIONS = {
'argv_emulation': True,
'packages':['pygame']}
我也会尝试查看/Users/luis/Desktop/py2appexec/dist/myapp.app/Contents/Resources/
并查看提到的文件,看看是否缺少某些东西。我缺少图像,尽管我认为您的问题可能会有所不同。一旦我将图像添加到文件夹中,它就可以正常工作。
推荐阅读
- python - 在线游戏报错“(”ConnectionAbortedError: [WinError 10053]”
- python - 是否可以在特定点将字符串分成两半?
- angular - 将数据转换为另一个数据并在表格上显示
- linux - cURL 以毫秒为单位设置重试超时
- apache-spark - Spark:执行者有不同的任务
- python - How to add a dataset identifier (like id column) when append two or more datasets?
- php - 如何在上传之前重命名和设置图像可接受的格式和大小
- java - 在java中对字符串列表进行分组
- java - 列表完成后进入下一个活动
- python - Flask-SQLalchemy 更新 current_user