FileNotFoundError: [Errno 2] No such file or directory: .constants.json

。_饼干妹妹 提交于 2020-01-11 11:32:06

问题


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'

Any suggestion?


回答1:


You might need to tell PyInstaller to include this file:

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')

Then run pyinstaller as:

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



回答2:


I am using Openpyxl version 2.5.12 Python 3.7 and Pyinstaller version 3.4

I am able to compile the exe without error. The command I am using is as follows:

pyinstaller --onefile --icon ABC.ico "..\\src\\src_file.py"


来源:https://stackoverflow.com/questions/36076319/filenotfounderror-errno-2-no-such-file-or-directory-constants-json

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!