Hi Brénainn.
Yes, it is installed via PyCharm under my venv. If I execute from within
PyCharm it runs fine and if I set my environment in a Windows command shell
it also works fine:
*D:\Development\Python\Experimental\Pyinstaller>call
venv\Scripts\activate(venv)
D:\Development\Python\Experimental\Pyinstaller>python pyinst_excel.py*
<= Silently executes - no error
*(venv)
D:\Development\Python\Experimental\Pyinstaller>dist\pyinst_excel.exeTraceback
(most recent call last): File "pyinst_excel.py", line 31, in <module>
add_generated_files_row(generated_files_excel, 1, date_generated) File
"pyinst_excel.py", line 25, in add_generated_files_row writer =
pd.ExcelWriter(generated_excel) File
"site-packages\pandas\io\excel\_openpyxl.py", line 18, in
__init__ModuleNotFoundError: No module named 'openpyxl'[15952] Failed to
execute script
pyinst_excel
*<= Executed after re-generating with pyinstaller command below
I am using a BAT file to generate the executable, which ensures that my
virtual environment is set when I generate:
*call venv\Scripts\activate*
*pyinstaller --onefile --hidden-import _openpyxl --hidden-import
xlsxwriter --hidden-import openpyxl --hidden-import xlwt --clean
pyinst_excel.py*
The xref-pyinst_excel.html file includes:
pandas._libs.json
c:\users\cbostock\appdata\local\programs\python\python38\lib\site-packages\pandas\_libs\json.cp38-win_amd64.pyd
imports: pandas._libs
imported by: pandas • pandas.io.excel._xlsxwriter • pandas.io.excel._xlwt •
pandas.io.json._json • pandas.io.json._table_schema
...
pandas.io.excel Package
imports: pandas.io • pandas.io.excel._base • pandas.io.excel._openpyxl •
pandas.io.excel._util • pandas.io.excel._xlsxwriter • pandas.io.excel._xlwt
imported by: pandas.io.api • pandas.io.excel._base •
pandas.io.excel._odfreader • pandas.io.excel._openpyxl •
pandas.io.excel._pyxlsb • pandas.io.excel._util • pandas.io.excel._xlrd •
pandas.io.excel._xlsxwriter • pandas.io.excel._xlwt •
pandas.io.formats.excel
'openpyxl.style' MissingModule
imported by: pandas.io.excel._openpyxl
'openpyxl.styles' MissingModule
imported by: pandas.io.excel._openpyxl
...
xlsxwriter MissingModule
imported by: pandas.io.excel._xlsxwriter • pyinst_excel.py
xlwt MissingModule
imported by: pandas.io.excel._xlwt • pyinst_excel.py
In total, there are roughly 50 missing modules shown in the html file. I
have just listed the ones which are immediately relevant.
Thanks,
Clive
On Thursday, 13 August 2020 at 13:53:03 UTC+1 bwoodsend wrote:
> Do you have openpyxl installed (i.e. does import openpyxl work normally)?
> Pandas tries a range of backends to read and write xlsx files - you need to
> ensure that the one you tell PyInstaller to include is the one that you
> actually have. For reading it’s usually xlrd and writing either xlsxwriter
> or xlwt. Whichever one(s) you have you should mark as hidden imports.
>
> If that isn’t the problem then navigate to
> build/pyinst_excel/xref-pyinst_excel.html and find openpyxl in it. It
> should say if it could find it and why it didn’t include it there.
>
> Brénainn
>
--
You received this message because you are subscribed to the Google Groups
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyinstaller/fba0a3ad-83a7-476c-b49c-e4d517bb00ben%40googlegroups.com.