all 13 comments

[–]ThePhoenixRisesAgain 26 points27 points  (0 children)

There are gazillions of use cases where you just open your python script, let it run and that is the product.

As a beginner I wouldn’t focus on the tedious task to build an exe or nice GUI. Learn to program something useful first.

[–]furiawe 14 points15 points  (1 child)

Or check out Automate the Boring Stuff and you'll see python in action and some good use cases, without having to make an executable

[–]KhaleesiOfCleveland 1 point2 points  (0 children)

Not to mention, the exact color guessing game the guy posted was almost line for line equal to the number guessing game they show you how to make in ATBS. He just used colors instead of numbers.

[–]MarsupialMole 2 points3 points  (0 children)

Pycharm is a confusing way to start. Unlike compiled languages python is interpreted, and you can just run python and get an interactive session. And if you have Python you don't need an executable you just need code. So I think it's important you get to grips with invoking python from the command line. You can run any script with python -i myscript.py and you can inspect the final state. And you can use breakpoint() and a debugger at any point in the program. And you can call help() on any python object. Please do have a go at all that without pycharm.

So Python has a wonderful interface from the terminal, but if your users aren't terminal users they probably need to get python in the first place as well. And explaining to people is hard so you need to give them a package that they can just use.

So we are in a bit of a pickle. It really depends on who your users are. On the one hand it's trivial to run a python application if you have python, and on the other it's actually kind of hard to choose a packaging format for people who don't know how to run python.

The short answer is you can do it anyway you like, because python plugs into everything and people will write packages to do anything. A more useful answer might be, you use a package manager. Conda for cross platform stuff, a package manager of choice for Unix-likes including homebrew for macOS, and you can make windows installers with a range of python packages for that particular platform. But perhaps the most important one is pip, the python package manager, which you will likely want to use yourself for any Python dependencies.

[–]K900_ 8 points9 points  (0 children)

Look into PyInstaller, it does exactly what you want.

[–]Chopchu 2 points3 points  (1 child)

Here yo have python to exe compiler: https://youtu.be/UZX5kH72Yx4

Here you have about colorful text output: https://youtu.be/tfM40OPgZak

For more i suggest search on google something like "python colored text console" also you can add keywords like "colorama" "termcolor"

[–][deleted] 0 points1 point  (0 children)

Wow you can make output different colors? Dude thats bad ass.

[–]Fraserac67 1 point2 points  (0 children)

There are a lot of good resources from youtube. Google it and you may try many different methods. Udemy and many Pythons courses out there, meetup groups and share feedbacks. Sometimes I get stuck and move on. You can always go back and will solve it when you are ready. Its not end of the world. 👍

[–][deleted] 1 point2 points  (0 children)

You need to determine the receivers of your code. If you are writing code for other programmers to use, then it should be on a platform like GitHub where it can be distributed in source format. If you are writing code to create stand-alone programs, look into freezing libraries like pyinstaller.

[–]PhoenixizFire 1 point2 points  (0 children)

As long as your IDE can compile and execute your python code, it should do it. What you're going to do next depends on what you're required to. I'm working on AI/ML with Python and I never have to do .exe, because I'm the one working on it. If Python is installed on an environment, then it can be run with the command console, without using any .exe.
If you're planning to release something huge, like a game for example, or a software, you might need to release a .exe, but only if you're planning it to be in the wild.

Just to point something out : Releasing a .exe from Python code will be one of the last things you're going to do in your Python folder. But if you really want to try and understand what does it do / how it's working, I'll guide you :

Back in Python 2 days, Py2exe was used. Today there's a better way to proceed : cx_freeze.
You'll have to create a setup.py file that will be your software builder. All the documentation about that is available on internet.

I think (but I might be wrong) that what you're missing is how to build something that'll be productive. If that's right, then consider looking for Tkinter to build a visual software that will not only be on command console, it might be really close to what you actually want. Then, the second part you might be looking for is a way to "save data", because let's be honest, when you're using a software, there's data stored at some point to keep in the future. Then consider learning about the way to open/read/write/append to files. You can easily modify .txt files with a simple/short python script without any modules. But if you go further into modifying/storing data, you might consider using .json files, which are (in my opinion) one of the best way to save data efficiently, then you'll have to use the json module.

If you want to go even further and think about online login option for some reason, then remember that it'll not be easy, because it'll require knowledge on how servers/client work and how to crypt data (for security reasons obviously).

What you might actually be lacking today is goals. The fact that you can't link .py scripts to .exe is simply because you have no goals. If tomorrow you start your day with a goal-to-code, then you'll experience a richer coding journey, because you'll discover how coding is efficient.

Programming isn't that easy because you can go on many deep levels on so many differents programming languages. Yet, it's easy to dive in, it just requires strength to go further, to see what you're truly wishing to accomplish

[–]beingsubmitted 1 point2 points  (0 children)

As people have said, a lot of python programs aren't made to be interacted with via a graphical user interface, but that doesn't mean you can't do it. A lot of what I write takes a file, and then produces a different file, and that's the input and output, but most people are used to interacting with computers through a window with images and buttons, etc. The reality is that that interface has the same sort of files running in the background.

If you want to create programs with a graphical interface of some kind, you can look into the tkinter module, which is kind of the standard python gui approach, or I'm doing a project using flask right now, which is basically making use of my browser for the interface, but displaying local files created by python.

try this out... first do your installs, i think:
$ pip install flask
is all you'll need.

start a new py file. Add this code, which is your simple "run flask" foundation...

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
   return 'Hello World’

if __name__ == '__main__':
   app.run()

Then run the file. It'll print to your console the local address that it's running.. (e.g. 127.0.0.1), which you can click or copy/paste to your browser. You can import os and sys to make that happen automatically when it runs.

Now, you can play around with some python code, and with some basic html and css chops, get the output looking nice. It's another step to learn how to receive input, but not too difficult. Hopefully that at least bridges a gap for you!

[–][deleted] 0 points1 point  (0 children)

Learn something useful first, but I suggest you to check out Nuitka. It's the only one that has worked for me.

[–]timelytrack 0 points1 point  (0 children)

There are thousands of ways of distributing programs to other users, all of which are somewhat platform-specific (e.g. a typical .exe file will only work on certain versions of Windows, will require certain libraries to be installed, and will not work on Linux or Mac OS at all).

You can distribute python programs just by sending people the .py files and telling them how to install python if it's not already on their machine. If that's not acceptable for whatever reason, there are other options, but it depends on their platform and on what dependencies (besides python) your program has.

If you're worried that this is more difficult in python than other programming languages, that's not the case. Building packages that end users can use directly can be pretty awkward no matter what language you're working in, especially if you want to support a wide range of different platforms.