Skip to content

Instantly share code, notes, and snippets.

@panda1100
Forked from GaryLee/hook-openpyxl.py
Created September 29, 2018 13:42
Show Gist options
  • Save panda1100/dbb64017ba385bce6e1ea246861120c7 to your computer and use it in GitHub Desktop.
Save panda1100/dbb64017ba385bce6e1ea246861120c7 to your computer and use it in GitHub Desktop.
Fix ".constants.json" not found issue when using Pyinstaller to pack openpyxl.
# When you're encountering following error.
# > IOError: [Errno 2] No such file or directory: 'C:\\Users\\username\\AppData\\Local\\Temp\\_MEI502322\\openpyxl\\.constants.json'
#
# This solution tested under Python 2.7.10 and Pyinstaller 3.0.
#
# Put this file to your script folder.
# Add this hook to your distribution by
# > pyinstaller --onefile --additional-hooks-dir=. yourscript.py
#
from PyInstaller.utils.hooks import collect_data_files
# Instruct pyinstaller to collect data files from openpyxl package.
datas = collect_data_files('openpyxl')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment