2

I wrote a python program in windows, then used pyinstaller to make it an .exe file. but the python program won't work in linux. why?

K7AAY
  • 17,202
wtb
  • 21

2 Answers2

4

It's very likely the program you wrote will work in Ubuntu, but because Linux and Windows have very different API structure, you would need to recompile or run the program in a Python interpreter on the Linux system to have it work. Linux in general doesn't recognize Windows .exe files, though if you have Wine installed, your system may attempt to run the program as if it were a Windows program, using Wine to service its system calls -- and this might even work, depending how your pyinstaller structures the executable.

Zeiss Ikon
  • 5,128
2

As mentioned in other answer try running in Python interpreter before compiling.

It is likely some code will have to be changed. For example if your original program contains:

INPUT_FNAME='\Documents\python_datain\today.csv

It would have to be change to:

INPUT_FNAME='~/Documents/python_datain/today.csv'

If it's low level python and does such things as moving mouse on screen, closing popup browser windows and adjusting screen brightness and color temperature many changes will be needed with added calls to xdotool, xrandr and possibly wmctrl.

  • And Windows has different line endings, as well. – Davidw Jan 31 '20 at 02:21
  • 1
    @Davidw good point about \r in Windows vs. \n in Linux as I believe you mean. We could go on to say how Gtk doesn't support some features in Windows which it supports in Linux. – WinEunuuchs2Unix Jan 31 '20 at 03:19