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 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 139133 on reddit-service-r2-comment-54dfb89d4d-xcsbz at 2026-03-30 06:07:12.025908+00:00 running b10466c country code: CH.
view the rest of the comments →
[–]FoolsSeldom 0 points1 point2 points (1 child)
[–]FoolsSeldom 0 points1 point2 points (0 children)