I have made a POO python script that parse some excel. So on Pycharm when I run my code it works very nicely but since I tried to write a batch file I encounter some issues.
The returned error is :
L:pathtomyfolder>C:UsersAppDataLocalPython3.8.2python.exe
L:pathtomyfolder..sourcesScript.py --file %~dp0..testsresults.xlsx
Failed to copy the provided Excel file. Aborting
Traceback (most recent call last):
File "L:pathtomyfolder..sourcesScript.py", line 318, in <module>
main()
File "L:pathtomyfolder..sourcesScript.py", line 305, in main
column = Script_obj.get_column()
File "L:pathtomyfolder..sourcesScript.py", line 90, in get_column
for cell_row in self.worksheet.iter_cols(min_row=11, max_row=11, min_col=7):
AttributeError: 'Script' object has no attribute 'worksheet'
L:pathtomyfolder>echo "1"
"1"
I don’t understand why attributes of my object are not known, do I miss something?
This is my .bat:
echo on
set "SCRIPT_DIR= %~dp0..sourcesScript.py"
set "file= %%~dp0..testsresults.xlsx"
echo %config%
C:UsersAppDataLocalPython3.8.2python.exe %SCRIPT_DIR% --file %file%
echo "%ErrorLevel%"
pause
I have corrected some mistakes on my code but still I don’t get why it works on Pycharm and why not with my .bat.
I checked these answer and answer, but I don’t think it is the same issue.