Skip to content

Instantly share code, notes, and snippets.

@GaryLee
Created November 30, 2015 06:44
Show Gist options
  • Save GaryLee/d191f239acf2f47bec93 to your computer and use it in GitHub Desktop.
Save GaryLee/d191f239acf2f47bec93 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')
@pythonwood
Copy link

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment