Macos 没有找到合适的映像
我的系统上安装了PyInstaller 4.0版。我正在尝试使用python 3.7.3构建python脚本。此python脚本导入具有自己的导入语句的其他python脚本 我正在使用命令进行构建: pyinstaller--noconfirm--clean script_to_build.py 但是,当我运行构建的新二进制文件时,会出现以下错误: 当文件被建立时,在DIST文件夹中有一个带有两个文件的基础文件夹,即.Buffy.cPython -3M-达尔文。SO和InL.cPython -37 m DARWIN。因此,它还在抱怨缺少基础库。此错误消息的含义是什么?如何修复它Macos 没有找到合适的映像,macos,build,pyinstaller,python-3.7,Macos,Build,Pyinstaller,Python 3.7,我的系统上安装了PyInstaller 4.0版。我正在尝试使用python 3.7.3构建python脚本。此python脚本导入具有自己的导入语句的其他python脚本 我正在使用命令进行构建: pyinstaller--noconfirm--clean script_to_build.py 但是,当我运行构建的新二进制文件时,会出现以下错误: 当文件被建立时,在DIST文件夹中有一个带有两个文件的基础文件夹,即.Buffy.cPython -3M-达尔文。SO和InL.cPython -3
Traceback (most recent call last):
File "PyInstaller/loader/pyiboot01_bootstrap.py", line 144, in __init__
File "ctypes/__init__.py", line 348, in __init__
OSError: dlopen(./dist/script_to_build/Foundation, 6): no suitable image found. Did find:
./dist/script_to_build/Foundation: not a file
./dist/script_to_build/Foundation: not a file
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "script_to_build.py", line 66, in <module>
import script1
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "/Library/Python/3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "script1.py", line 19, in <module>
import pyautogui
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "/Library/Python/3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "pyautogui/__init__.py", line 241, in <module>
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "/Library/Python/3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "mouseinfo/__init__.py", line 100, in <module>
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "/Library/Python/3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "rubicon/objc/__init__.py", line 15, in <module>
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "/Library/Python/3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "rubicon/objc/runtime.py", line 89, in <module>
File "rubicon/objc/runtime.py", line 66, in load_library
File "PyInstaller/loader/pyiboot01_bootstrap.py", line 146, in __init__
__main__.PyInstallerImportError: Failed to load dynlib/dll './dist/script_to_build/Foundation'. Most probably this dynlib/dll was not found when the application was frozen.
回溯(最近一次呼叫最后一次):
文件“PyInstaller/loader/pyiboot01_bootstrap.py”,第144行,在uu init中__
文件“ctypes/_init__.py”,第348行,在_init中__
OSError:dlopen(./dist/script\u to\u build/Foundation,6):未找到合适的映像。确实发现:
./dist/script\u to\u build/Foundation:不是文件
./dist/script\u to\u build/Foundation:不是文件
上述异常是以下异常的直接原因:
回溯(最近一次呼叫最后一次):
文件“script_to_build.py”,第66行,在
导入脚本1
文件“”,第983行,在_find_和_load中
文件“”,第967行,在“查找”和“加载”中解锁
文件“”,第677行,在\u加载\u解锁
exec_模块中的文件“/Library/Python/3.7/site packages/PyInstaller/loader/pyimod03_importers.py”,第493行
exec(字节码、模块、指令)
文件“script1.py”,第19行,在
导入pyautogui
文件“”,第983行,在_find_和_load中
文件“”,第967行,在“查找”和“加载”中解锁
文件“”,第677行,在\u加载\u解锁
exec_模块中的文件“/Library/Python/3.7/site packages/PyInstaller/loader/pyimod03_importers.py”,第493行
exec(字节码、模块、指令)
文件“pyautogui/_init__uu.py”,第241行,在
文件“”,第983行,在_find_和_load中
文件“”,第967行,在“查找”和“加载”中解锁
文件“”,第677行,在\u加载\u解锁
exec_模块中的文件“/Library/Python/3.7/site packages/PyInstaller/loader/pyimod03_importers.py”,第493行
exec(字节码、模块、指令)
文件“mouseinfo/_init__.py”,第100行,在
文件“”,第983行,在_find_和_load中
文件“”,第967行,在“查找”和“加载”中解锁
文件“”,第677行,在\u加载\u解锁
exec_模块中的文件“/Library/Python/3.7/site packages/PyInstaller/loader/pyimod03_importers.py”,第493行
exec(字节码、模块、指令)
文件“rubicon/objc/_init__.py”,第15行,在
文件“”,第983行,在_find_和_load中
文件“”,第967行,在“查找”和“加载”中解锁
文件“”,第677行,在\u加载\u解锁
exec_模块中的文件“/Library/Python/3.7/site packages/PyInstaller/loader/pyimod03_importers.py”,第493行
exec(字节码、模块、指令)
文件“rubicon/objc/runtime.py”,第89行,在
文件“rubicon/objc/runtime.py”,第66行,在load_库中
文件“PyInstaller/loader/pyiboot01_bootstrap.py”,第146行,在uu init中__
__main.pyInstallerImporter:未能将dynlib/dll./dist/script\u加载到\u build/Foundation'。很可能在冻结应用程序时未找到此dynlib/dll。
终于明白了。以下是有效的更新命令:
pyinstaller --add-binary "/System/Library/Frameworks/Foundation.framework/Versions/C/Resources/BridgeSupport/Foundation.dylib:." --onefile --noconfirm --clean script_to_build.py
我可以用这个来编译程序,但是在执行二进制文件时,我得到了错误“../../../../../../../../../../../../../../../../Library/Python/3.7m/include/pyconfig.h无法提取!”为了修复这个错误,我不得不修改函数relpath\u to\u config\u或\u make(filename)
file/Lirary/Python/3.7/site packages/PyInstaller/utils/hooks/init.py如下所示:
def relpath_to_config_or_make(filename):
"""
The following is refactored out of hook-sysconfig and hook-distutils,
both of which need to generate "datas" tuples for pyconfig.h and
Makefile, under the same conditions.
"""
# Relative path in the dist directory.
prefix = _find_prefix(filename)
rel_path = os.path.relpath(os.path.dirname(filename), prefix)
if '../' in rel_path and is_darwin:
new_path = os.path.relpath(os.path.abspath(rel_path), os.path.expanduser('~'))
else:
new_path = os.path.relpath(os.path.dirname(filename), prefix)
return new_path