我正在尝试使用使用 skyfield 模块/API 的 pyinstaller 打包一个脚本,并且它会构建,但是当我运行它时,它会说找不到nutation.npz
(包含在nutationlib.py
_arrays = load_bundled_npy('nutation.npz')
.
我尝试过使用--onefile
,而不是使用它。--add-data
并且--add-binary
不喜欢它。--hidden-imports
没有帮助。--debug=imports
不是太有用,但附加的日志来自--debug=all
编译。
关于如何强制 pyinstaller 将 nutation.npz 包含到内置的 .exe 中的任何想法,以便在提取/运行时它在那里?
import skyfield.nutationlib # PyInstaller PYZ
Traceback (most recent call last):
File "satvis.py", line 9, 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 "c:\users\fox\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\skyfield\api.py", line 11, 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 "c:\users\fox\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\skyfield\constellationlib.py", line 29, 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 "c:\users\fox\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\skyfield\timelib.py", line 14, 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 "c:\users\fox\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\skyfield\nutationlib.py", line 7, in <module>
File "site-packages\skyfield\functions.py", line 143, in load_bundled_npy
File "pkgutil.py", line 637, in get_data
File "c:\users\fox\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 471, in get_data
with open(path, 'rb') as fp:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\fox\\AppData\\Local\\Temp\\_MEI89762\\skyfield\\data\\nutation.npz'
[44412] Failed to execute script satvis