0

I want to convert one .py file to .exe from Linux Ubuntu. I found pyinstaller for this. But when pyinstaller runs from Linux it makes file executable only for Linux and when pyinstaller runs from Windows it makes .exe file for Windows. I want to convert .exe file from Linux for Windows. So how can i make it? I need an instruction.

P.S: if i cannot do it with pyinstaller, please write other tool.

4
  • Possible duplicate of Cross-compiling a Python script on Linux into a Windows executable Commented Aug 17, 2018 at 16:05
  • @Lodi that question isn't answered completely Commented Aug 17, 2018 at 16:06
  • 1
    Yes, it is. It says that you'll need to use a tool to virtually use windows inside linux. There's no other way Commented Aug 17, 2018 at 16:07
  • 1
    Take a look here andreafortuna.org/technology/… , This article teaches how to do it Commented Aug 17, 2018 at 16:07

1 Answer 1

1

If you know how to use Docker, that may be an easy enough way to do it. The relevant docker images can be found here.

From the documentation there:

There are two containers, one for Linux and one for Windows builds. The Windows builder runs Wine inside Ubuntu to emulate Windows in Docker.

To build your application, you need to mount your source code into the /src/ volume.

The source code directory should have your .spec file that PyInstaller generates. If you don't have one, you'll need to run PyInstaller once locally to generate it.

If the src folder has a requirements.txt file, the packages will be installed into the environment before PyInstaller runs.

For example, in the folder that has your source code, .spec file and requirements.txt:

docker run -v "$(pwd):/src/" cdrx/pyinstaller-windows 

will build your PyInstaller project into dist/windows/. The .exe file will have the same name as your .spec file.

docker run -v "$(pwd):/src/" cdrx/pyinstaller-linux 

will build your PyInstaller project into dist/linux/. The binary will have the same name as your .spec file.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.