Hello!
I want to make an executable file from my Python script (Python
version 3.11.5, Anaconda) using Pyinstaller. The main function of the
script is to access data from an excel file and provide this data in
different files for other scripts. When I run the script in Spyder it
works totally fine. However, if I use pyinstaller, the following error occurs:
ImportError: Missing optional dependency 'openpyxl'. Use pip or conda to install openpyxl.
[24544] Failed to execute script 'mwe' due to unhandled exception!
I want to make an executable file from my Python script (Python version 3.11.5, Anaconda) using Pyinstaller. The main function of the script is to access data from an excel file and provide this data in different files for other scripts. When I run the script in Spyder it works totally fine. However, if I use pyinstaller, the following error occurs:
ImportError: Missing optional dependency 'openpyxl'. Use pip or conda to install openpyxl. [24544] Failed to execute script 'mwe' due to unhandled exception!I reinstalled openpyxl and also in Anaconda it is displayed as installed. I further created a new environment as recommended in some other posts about this problem. I tried pyinstaller --hidden-import openpyxl. Furthermore I tried pyinstaller --name=mwe --onefile mwe.py and then to add hiddenimports=[ 'openpyxl']' to the resulting mwe.spec file.
But nothing worked so far.
The main function of my python script to access an excel file and print the data in a new txt file:
import pandas as pd
obs = (pd.read_excel('FINIFLUX.xlsx', usecols='F', header=2)).dropna()
np.savetxt('observation_points.txt', obs)
As I am pretty new to Python and especially to pyinstaller, I would be glad if somenone could help me!