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?
-
4read the errors when you run the executable on the command line. PyInstaller is not designed to really be cross-platform you have to crossbuild and use different binary libraries underneath the hood to make it work in Linux, if you're going to write a python program in Windows write it as pure Python and then just copy the application without wrapping it in PyInstaller into the Linux environment and run it with Python on-system or in a venv. – Thomas Ward Jan 30 '20 at 18:00
-
Also, check your Python versions. A Python app written for 2.7 generally will not work in 3.6, for example. – K7AAY Jan 30 '20 at 18:44
-
Does this answer your question? Is there a way to run .exe in Ubuntu? – karel Jan 31 '20 at 04:19
-
1Possible duplicate of Executing script from shell problem – karel Jan 31 '20 at 04:25
2 Answers
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.

- 5,128
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
.

- 102,282
-
-
1@Davidw good point about
\r
in Windows vs.\n
in Linux as I believe you mean. We could go on to say howGtk
doesn't support some features in Windows which it supports in Linux. – WinEunuuchs2Unix Jan 31 '20 at 03:19