I have a python program I wrote to parse through student data from powerschool and automatically generate a letter with their missing assignments to send to their parents. This program works great, but I am running into a problem trying to export it to an executable for my coworkers to use. WHenever I run PyInstaller, the resulting exe fails with the following error:
'ModuleNotFoundError: No module named 'docx'
This is the same issue found in this stackoverflow post, but I have been unable to get the solution to work for me. As directed in the linked post, I created the .spec file below, but I still get the same error as before.
# -*- mode: python ; coding: utf-8 -*-
import sys
from os import path
site_packages = next(p for p in sys.path if 'site-packages' in p)
block_cipher = None
a = Analysis(
['gradeReport2.py'],
pathex=[],
binaries=[],
datas=[('logo.png', 'resources'), (path.join(site_packages,"docx","templates"), "docx/templates")],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
optimize=0,
)
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
name='gradeReport2',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
When I run pyinstaller with the spec file, I get the following error, which I am not sure how to address. When I navigate to the …site-packages folder, I can see that docx is not there, but I don’t know why that is or where it would be instead.
Unable to find 'C:\Users\name\AppData\Local\Programs\Python\Python312\Lib\site-packages\docx\templates' when adding binary and data files.