1

I have proceeded to generate an executable file using pyinstaller, once it has finished the corresponding files are generated, then: In my windows console I apply this command: pyinstaller --onefile program_with_excel.py

I use this command to compile everything into a single.exe file, so that I can use it on another pc.

Once this is done, I open my executable located in the 'dist' folder and when doing so I have detected several problems:

  1. My executable file 'program_with_excel.exe' is too heavy for what I am trying to do, a few simple calculations. (317,948 KB)

  2. When I open it, the following error appears and then my application closes:

enter image description here

I suspect it is because to run my program I use an excel sheet using 'pandas' where I place data and they are calculated with my program. How could this be resolved?

What would be the solution for this problem and be able to work with my executable?

I also attach a rar with my program and my excel sheet: RAR_EXAMPLE

Best regards.

DaniV
  • 489
  • 2
  • 9
  • Can you create a minimal example which still exhibits similar problems? See how to create a [mcve]. – Peter Wood Jul 06 '20 at 22:49
  • The size issue is something that you have to deal with when using Pandas. It's a pretty sizeable distribution and it adds a lot of dependencies to your script, hence the large size. – NotAName Jul 06 '20 at 22:50
  • I suspect you gave a relative path to 'Data.xlsx' and now python cant find it. If this is the case you can resolve it by giving an absolute path to 'Data.xlsx' – Ahmet Jul 06 '20 at 22:51
  • Friend, I could share the generated file with you but it is very heavy, if you could help me generating it from your machine it would be great, I already provided you with my script and my .xlsx. @Peter Wood. – DaniV Jul 06 '20 at 23:04
  • If you can use `csv` files instead of `xlsx` you can use Python's builtin [**`csv`**](https://docs.python.org/3/library/csv.html) module easily. No need for [tag:pandas]. – Peter Wood Jul 06 '20 at 23:13

1 Answers1

1

The exe needs to have access to all its dependencies, just like the python script. If you moved it then it may not have that access. It appears from the error that this is the problem. A common way these exe files are transported is by putting it and each dependency in a zipped folder and using NSIS.

Cresht
  • 1,020
  • 2
  • 6
  • 15