首页 > 解决方案 > 在使用 Astroquery 的 python 脚本上使用 PyInstaller 编译 exe 文件时出现 FileNotFoundError

问题描述

我正在尝试编译我为研究编写的 python 脚本的 exe,以便我可以与没有安装 python 的实验室合作伙伴共享它。

要创建可执行文件,我只是pyinstaller opposition_calc.py在 anaconda 提示符中输入(opposition_calc.py 是我的 python 脚本)。

编译过程似乎工作正常,但是,当从命令行执行 exe 时,将为 astroquery 模块报告 FileNotFoundError。

Traceback (most recent call last):
  File "opposition_calc.py", line 2, 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 "PyInstaller\loader\pyimod03_importers.py", line 540, in exec_module
  File "astroquery\__init__.py", line 29, in <module>
  File "astroquery\__init__.py", line 22, in _get_bibtex
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\jusge\\OneDrive\\Desktop\\distribution_calc\\opposition_calculator\\opposition_calc\\dist\\opposition_calc\\astroquery\\CITATION'
[1172] Failed to execute script opposition_calc

据我所知,它正在寻找一个名为“astroquery”的目录并且找不到它。但是,分发文件夹中没有标题为“astroquery”的目录,因此很明显在编译过程中没有包含它。我对 python 或 pyinstaller 不是很熟悉,所以我不太确定如何确保它被包含在内。

标签: python-3.xpyinstallerastroquery

解决方案


推荐阅读