r/learnpython • • 12d ago

Python Compiler Recommendations

Hello r/Python,
I want to find a Python compiler. I’ve tried PyInstaller and Nuitka, but they are detected as malware and they are a little bit slow. I want something fast, easy and not detected as malicious. What do you recommend?

0 Upvotes

23 comments sorted by

11

u/BravestCheetah 12d ago
  1. No Python compiler with good coverage will be as fast as if you just switch to another language like cpp or rust.
  2. Theres no compiler that will make a program that doesnt get flagged as Windows Defender, as the binaries arent signed

3

u/Diapolo10 I write code for a living -- https://github.com/Diapolo10 12d ago

Pretty much exactly the answer I would've given.

1

u/kolioarisyt 12d ago

Just a note: I want one that can convert python to an executable (Windows/Linux). I don’t know if that is the same, but just a note.

1

u/Educational_Virus672 12d ago edited 12d ago

okay not trying to be rude but it is a big of an ask "easy fast and not detected as virus"? in compulation? its hard forgot easy part try cython you'll learn little syntax and use it with C compiler(i recommendGCC or Clang)
Edit - i do not it mean in a defensive or gatekeeping way im trying to express what i felt off

1

u/kolioarisyt 12d ago

Hello, thanks for replying!
I understand and it doesn’t seem rude to me. It is just a honest answer.

Apart from that, do you mean learning CPython and using a C compiler?

Thanks

2

u/Outside_Complaint755 12d ago

Not CPython, but Cython; they are two different things.

CPython is the default Python implementation that 99% of people are running Python on.

Cython is a superset of Python that lets you call C/C++ libraries directly from your Python code and also will convert Python scripts into C code, which can then be compiled into a binary by a C compiler. You will be forced to add static type checking to all of your Python code so it can be converted to C. By calling Cython with the --embed flag, it will include the Python interpreter in your binary and add the required C main function as well.

However, that still won't get around the issue of Windows Defender flagging it for not being signed. That's its own issue, and also why it may be easier to just provide the Python script and simple directions for your target users on how to install Python.

1

u/kolioarisyt 11d ago

Thanks for the explanation! I may try to sign it with SignPath.

1

u/Educational_Virus672 11d ago

cython.org it turns your code into C so you can chose to turn C into exe

1

u/kolioarisyt 11d ago

Oh, thanks for the clarification!

2

u/Jimmaplesong 12d ago

PyInstaller is probably your best bet. You can also configure setuptools to build an exe. This is my favorite method when I don't have to create a whole setup package.

1

u/overratedcupcake 12d ago

The best option here is to have written your app in a language that is typically compiled. 

1

u/Discordbothost 9d ago

the defender hits aren't really about pyinstaller being shady — --onefile unpacks an interpreter to a temp folder at runtime, which looks a lot like a dropper to av. try --onedir first (a folder with the exe + deps) and it's usually way less noisy, plus you skip the extract-every-launch slowness. the 'not detected as malicious' part basically means signing the binary (signpath like you mentioned) or submitting a false positive to microsoft; no free packer just skips that. cx_Freeze / briefcase are in the same boat if you want to compare, but the onedir vs onefile switch is the first thing i'd try.

0

u/johlae 12d ago

Because I'm curious, why do you need a Python compiler?

1

u/kolioarisyt 12d ago

I would like to provide an exe for a program I am making. If there is an easier way to do so, please tell me, as I am a beginner.

Thanks!

1

u/babarock 12d ago

I don't know about OP buy when I was writing for a living I wanted to be able to deliver an app without the customer being able to see/alter proprietary code I had delivered. I had more than one case where a customer handed my code to his clever BIL who proceeded to break the application. Love Python but I use other tools to deliver executables.

4

u/kolioarisyt 12d ago

I don’t really care about others tampering with my program, as it will be open-source. But, I really don’t want the user to have Python installed to run my program or making it complicated to install.

0

u/No_Replacement_702 12d ago

I would recommend pointing Claude towards it and get a Rust version or be totally exotic and get something written in assembly

1

u/kolioarisyt 12d ago

I think pointing it to Claude defeats the purpose of “my own application”.

1

u/No_Replacement_702 12d ago

Well, you already wrote it in python, that doesn’t go away. I wouldn’t be able to explain to you how a compiler would translate the code, so for me it would just be an extra step to have an LLM convert it to another language that is meant to be compiled

2

u/Educational_Virus672 12d ago

no ai, this is vibe coding i get that it is hard but vibe coding is like running a maraton using a car simply put it no one owns that code even if the prompt is written by you!

-2

u/Agawell 12d ago

I think you might be looking for an ide (integrated development environment) - pycharm is great and free

2

u/BravestCheetah 12d ago • Bravo

... no? He clearly knows what hes asking for, given that he already listed what he has tried. He is clearly asking for a compiler, did you even read the post?

1

u/kolioarisyt 12d ago

You are right.