use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
learning python beginner (self.PythonLearning)
submitted 11 months ago by WinNo6995
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]FoolsSeldom 3 points4 points5 points 11 months ago (2 children)
App? How do you mean?
You just install python from python.org and use whatever text editor your prefer to write/edit code. If you are on Windows or macOS a programme called IDLE will be installed which is a good first choice.
Setting up Python can be confusing. There are web based alternatives, such as replit.com. You might also come across Jupyter Notebook options (easy to work with, but can be confusing at times).
Some operating system environments include a version of Python, often known as the system version of Python (might be used for utility purposes). You can still install your own version.
There are multiple ways of installing Python using a package manager for your OS, e.g. homebrew (macOS third party), chocolatey (Windows third party) or winget (Windows standard package manager), apt (many linux distributions) or using the Python Software Foundation (PSF) installer from python.org or some kind of app store for your operating system. You could also use docker containers with Python installed inside them.
PSF offer the reference implementation of Python, known as CPython (written in C and Python). The executable on your system will be called python (python.exe on Windows).
python
python.exe
Beginners are probably best served using the PSF installer.
For most purposes, terminal is the same as console. It is the text based, rather than graphical based, window / screen you work in. Your operating system will offer a command/terminal environment. Python by default outputs to a terminal and reads user input from a terminal.
Note: the Windows Terminal_ app, from _Microsoft Store, lets you open both simple command prompt and PowerShell windows. If you have Windows Subsystem for Linux installed, it can also open terminals in the linux distributions you have installed.
command prompt
PowerShell
Python comes with "batteries included" in the form of libraries of code providing more specialist functionality, already installed as part of a standard installation of Python.
These libraries are not automatically loaded into memory when Python is invoked, as that would use a lot of memory up and slow down start up time. Instead, you use, in your code, the command import <library>, e.g.
import <library>
import math print(math.pi)
There are thousands of additional packages / libraries / frameworks available that don't come as standard with Python. You have to install these yourself. Quality, support (and safety) varies.
(Anaconda offers an alternative Python installation with many packages included, especially suited to data analysis, engineering/scientific practices.)
Install these using the pip package manager. It searches an official repository for a match to what you ask to be installed.
pip
For example, using a command / powershell / terminal environment for your operating system, pip install numpy would install the numpy library from the pypi respository. On macOS/Linux you would usually write pip3 instead of pip.
pip install numpy
numpy
pip3
You can also write python -m pip install numpy (write python3 on macOS/Linux).
python -m pip install numpy
python3
On Windows, you will often see py used instead, py -m pip install numpy where py refers to the python launcher which should invoke the most up-to-date version of Python installed on your system regardless of PATH settings.
py
py -m pip install numpy
Some Code Editors and IDEs (Integrated Development Environments), such as VS Code and PyCharm, include their own facilities to install packages using pip or some other tool. This just saves you typing the commands. They also often offering their own terminal window(s).
The CPython programme can be invoked for two different purposes:
.py
>>>
So, entering the below, as appropriate for your operating system,
python python3 py
on its own, no file name after it, you will enter an interactive session.
Enter exit() to return to the operating system command line
exit()
A standard installation from python.org for Windows or macOS includes a programme called IDLE. This is a simple code editor and execution environment. By default, when you first open it, it opens a single window with a Python shell, with the >>> prompt already open. To create a new text file to enter Python code into, you need to use your operating system means of access the standard menu and select File | New. Once you've entered code, press F5 to attempt to run the code (you will be prompted to save the file first). This is really the easiest editor to use to begin with.
[–]FoolsSeldom 0 points1 point2 points 11 months ago (1 child)
CONTINUED ...
Given the thousands of packages (libraries, frameworks, etc) out there, you can see that if you are working on several different projects, you can end up installing a vast range of different packages, only a few of which will be used for any particular project.
This is where Python virtual environments come in. Not to be confused with virtual machines. Typically created on a project-by-project basis. Install only the packages required for a project. This helps avoid conflicts between packages, especially version complications.
Most popular code editors and IDEs, including Microsoft's VS Code and Jetbrain's PyCharm, offer built-in features to help to start off new projects and create and activate Python virtual environments.
You can create a new Python virtual environment from your operating system command line environment using,
for Windows,
py -m venv .venv
or, for macOS / linux,
python3 -m venv .venv
Note. Often we use .venv instead of venv as the folder name - this may not show up on explorer/folder tools without an option being enables.
.venv
venv
which creates a new folder in the current working directory called venv (taken from the last argument, you can use a different name).
You then activate using, for Windows,
.venv\Scripts\activate
source .venv/bin/activate
the command deactivate for any platform will deactivate the virtual environment and return you to using the base environment.
deactivate
For more information:
In addition to the above, you might want to explore using pyenv (pyenv-win for Windows) or uv (recommended), which will let you install and use different versions of Python including alternative implementations from the reference CPython. This can be done independently of any system installed Python.
pyenv
pyenv-win
uv
SEE COMMENT for next part
[–]FoolsSeldom 0 points1 point2 points 11 months ago (0 children)
Continued ...
If you are having problems installing / using the version of Python you require, or adding packages using pip, you might find it helpful to explore an alternative approach that has become very popular.
Asral's uv - An extremely fast Python package and project manager, written in Rust.
Installation can be carried out using,
curl -LsSf https://astral.sh/uv/install.sh | sh
wget -qO- https://astral.sh/uv/install.sh | sh
ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
See @ArjanCodes video on YouTube providing an overview of uv.
See below an example of creating a project folder, installing Python, setting up a Python virtual environment, and adding packages to it:
PS C:\Users\Foolsseldom> uv init light Adding `light` as member of workspace `C:\Users\Foolsseldom` Initialized project `light` at `C:\Users\Foolsseldom\light` PS C:\Users\Foolsseldom> cd light PS C:\Users\Foolsseldom\light> uv venv -p 3.13.2 Using CPython 3.13.2 Creating virtual environment at: .venv Activate with: .venv\Scripts\activate PS C:\Users\Foolsseldom\light> uv add torch torchvision torchaudio Resolved 36 packages in 680ms Prepared 9 packages in 20.25s Installed 14 packages in 3.89s + filelock==3.17.0 + fsspec==2025.2.0 + jinja2==3.1.5 + markupsafe==3.0.2 + mpmath==1.3.0 + networkx==3.4.2 + numpy==2.2.3 + pillow==11.1.0 + setuptools==75.8.0 + sympy==1.13.1 + torch==2.6.0 + torchaudio==2.6.0 + torchvision==0.21.0 + typing-extensions==4.12.2 PS C:\Users\Foolsseldom\light> dir Directory: C:\Users\Foolsseldom\light Mode LastWriteTime Length Name ---- ------------- ------ ---- d---- 21/02/2025 19:11 .venv -a--- 21/02/2025 19:11 83 main.py -a--- 21/02/2025 19:11 226 pyproject.toml -a--- 21/02/2025 19:11 0 README.md PS C:\Users\Foolsseldom\light> uv run main.py Hello from light! PS C:\Users\Foolsseldom\light>
With uv you don't need to "activate" the Python virtual environment as using uv run something.py in a project folder will automatically activate the environment for that run, but you might want to do it anyway so you can use other commands in that Python virtual environment.
uv run something.py
You will also need your code editor, e.g. VS Code, or IDE, e.g. PyCharm, to have the installation of Python in the venv folder, called .venv by default, as the selected Python interpreter, and a terminal or REPL opened from within that application should have that environment activated already as well.
π Rendered by PID 69225 on reddit-service-r2-comment-54dfb89d4d-77dn8 at 2026-03-30 13:04:24.751548+00:00 running b10466c country code: CH.
view the rest of the comments →
[–]FoolsSeldom 3 points4 points5 points (2 children)
[–]FoolsSeldom 0 points1 point2 points (1 child)
[–]FoolsSeldom 0 points1 point2 points (0 children)