I am new to python, just installed today and have been playing around with brackets and Python. I am confused on how to get my code from brackets to run in python. My code in brackets was saved as print("happy to be here") and I saved it as happy.py. any help is greatly appreciated! Thank you!
Running Brackets code
|
Running Brackets code
|
|
Feb-13-2026, 02:43 AM
Well, get started right!
First look up: Setting up a Python Virtual Environment. Lots of info out there. Profis will set up a Virtual Environment for each new project, I believe. snippsat, a moderator and very experienced programmer here recommends a tool called uv for this task. The uv docs. Read this, then you will know how to set up your Virtual Environment. I don't know if you use Windows or Linux. In Linux we have a terminal called bash, you can do things from the command line. To run a Python programme in bash, not in an IDE, you must have the shebang as the first line, like this: #! /usr/bin/python3 Not sure what that looks like in Windows, I almost never use Win. #! /usr/bin/python3
print("Hello cruel world!")If I save this as happy.py in my Virtual Environment, I can run it in a bash terminal like this:(This is what I see in my bash terminal. GPE is my Python Virtual Environment) Once you have your Virtual Environment, you can start it like this in a bash terminal:Quote:peterr@peterr-Modern-15-B7M:~/PVE$ cd PVE && source GPE/bin/activate && python3 -m idlelib.idle My Virtual Environment is in a folder called PVE and is called GPE. You need to put your own Virtual Environment path and name in this. This will start Idle, which is a free IDE that comes with Python. At least for beginners, Idle is OK. The profis here prefer other IDEs I think! If you run into problems getting set up, ask here, I'm sure people will be glad to help. don't forget to read the docs!
A couple of things:
1. Don't post images, copy/paste as text and format using proper BBCode tags 2. Learn about different ways to execute python code. Basically: means you are in Python interactive shell, i.e. execute python code line by line as you enter it.You cannot execute shell/OS commands. They are executed in cmd/shell (that is when you have something lile C:\>to exit from python interactive mode use exit()e.g.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link Create MCV example Debug small programs |
|
|
Users browsing this thread: 1 Guest(s)
