FileNotFoundError:[错误2]没有这样的文件或目录:.constants.json [英] FileNotFoundError: [Errno 2] No such file or directory: .constants.json

查看:280
本文介绍了FileNotFoundError:[错误2]没有这样的文件或目录:.constants.json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用openpyxl编写了一个涉及excel表格操作的python脚本.使用python解释器,脚本运行良好.使用pyinstaller使单个Windows可执行文件并运行该程序后,其抛出错误:

I have coded a python script involving excel sheet manipulation using openpyxl. Script is running fine using python interpreter. Once I have made single windows executable using pyinstaller and running the program, its throwing error:

FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\....\\AppData\\Local\\Temp\\_MEI31842\\.constants.json'

有什么建议吗?

推荐答案

您可能需要告诉PyInstaller包含此文件:

You might need to tell PyInstaller to include this file:

在运行pyinstaller的目录中放置文件hook-openpyxl.py:

Put a file hook-openpyxl.py in the directory from where you run pyinstaller:

# hook-openpyxl.py

from PyInstaller.utils.hooks import collect_data_files

datas = collect_data_files('openpyxl')

然后以以下方式运行pyinstaller:

Then run pyinstaller as:

pyinstaller --additional-hooks-dir=. yourscriptname.py

这篇关于FileNotFoundError:[错误2]没有这样的文件或目录:.constants.json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆