Important
Our Software Development Project (SDP200) course focuses on Python, and we need to learn the fundamentals of Python to complete a mini-project by the end of the semester. I studied Python about six years ago, and a lot has changed since then. That is why I am relearning Python and documenting my findings, insights, and best practices in this repository.
Since some of you were clueless about how to use this repository for learning, here is an overview:
- Install pyenv and one or multiple versions of Python by following the Installation section. This needs to be done only once.
Open a new Command Prompt by typing cmd in the Start menu and do the following:
-
Select a preferred global version of Python:
pyenv global [VERSION]
* I am using Python 3.10.10
-
Create a virtual environment in your project directory:
python -m venv env
-
Activate the virtual environment:
env\Scripts\activate.bat
-
Install the required packages:
pip install -r requirements.txt
Having done that, we can run any script from this repository. Let's say, we want to run 03-f-string/01-huge-int.py, so we can type:
python 03-f-string/01-huge-int.py
Different projects require different packages that might depend on specific versions of Python. It is a good idea to have multiple versions of Python installed on the system. Therefore, we can switch to a particular version whenever necessary.
pyenv makes it easy to manage multiple versions of Python on a per-user basis. We will use pyenv-win to make it work on our Windows machines.
-
Press the ⊞ Windows key and type Powershell. Run it as Administrator.
-
Create a new directory under home by typing the following in the PowerShell terminal:
mkdir $HOME/.pyenv -
Download the code archive from the pyenv-win repository and extract the files from it.
-
Head over to the pyenv-win-master directory and copy the following files into the newly created .pyenv directory:
📁 pyenv-win 📄 .version
-
In the PowerShell terminal, type the following commands to set environment variables pointing to the installation folder:
[System.Environment]::SetEnvironmentVariable('PYENV',$env:USERPROFILE + "\.pyenv\pyenv-win\","User") [System.Environment]::SetEnvironmentVariable('PYENV_HOME',$env:USERPROFILE + "\.pyenv\pyenv-win\","User")
-
Having done that, add the bin folder to the PATH environment variable:
[System.Environment]::SetEnvironmentVariable('path', $env:USERPROFILE + "\.pyenv\pyenv-win\bin;" + $env:USERPROFILE + "\.pyenv\pyenv-win\shims;" + [System.Environment]::GetEnvironmentVariable('path', "User"),"User")
-
Close the current PowerShell and open a new instance. Then enable the execution of scripts by typing the following command:
Set-ExecutionPolicy unrestrictedType A (Yes to All) and hit enter.
Note
We might need to unblock the pyenv script if we encounter a security warning. We can do that by typing the following command:
Unblock-File $HOME/.pyenv/pyenv-win/bin/pyenv.ps1
-
Open a Command Prompt by typing cmd in the Start menu:
-
Verify the installation by typing pyenv in the terminal. If everything went well, we should see something like the following:
We are not done yet! We still need to install the specific versions of Python we want for our projects. Here is the command to install a specific version of Python using pyenv:
pyenv install [VERSION]I installed the following versions of Python for my projects:
* 3.10.10
3.11.9
3.12.2
3.13.0a1-win32
3.9.6Note
The asterisk symbol (*) before the version indicates the global Python version.
Command to make a version of Python globally available:
pyenv global [VERSION]Command to see the global Python version:
pyenv globalCommand to see the selected version of Python:
pyenv versionCommand to see all available versions of Python installed on the system:
pyenv versionsCommand to uninstall a specific version of Python:
pyenv uninstall [VERSION]When starting a new Python project, it is important to isolate its dependencies from those installed globally on our system to prevent any conflicts. We can do this by creating a new virtual environment.
-
Open a Command Prompt in the project directory. Type the following command:
python -m venv env
-
Activate the virtual environment by running the following script:
env\Scripts\activate.bat
-
Install the required dependencies by using the following command:
pip install [PACKAGE]
-
Having done that, deactivate the virtual environment:
env\Scripts\deactivate.bat
Command to install a specific package:
pip install [PACKAGE]Command to uninstall a specific package:
pip uninstall [PACKAGE]Command to list all installed dependencies:
pip listCommand to export the list of the installed dependencies:
pip freeze > requirements.txtCommand to install the dependencies from file:
pip install -r requirements.txtIn order to enable the formatting of .py files, do the following:
-
Install Black Formatter from the Visual Studio Marketplace.
-
Press ^ CTRL + ⇧ Shift + P to open the Command Palette and run Preferences: Open User Settings (JSON).
-
Add the following to the
settings.jsonfile:"[python]": { "editor.defaultFormatter": "ms-python.black-formatter", "editor.formatOnSave": true }
How to Install and Run Multiple Python Versions on Windows 10/11 | pyenv & virtualenv Setup Tutorial
Python Virtual Environments - Full Tutorial for Beginners
Python Full Course for Beginners [2025]
5 Useful F-String Tricks In Python
Changing the title bar color of tkinter windows
An introduction to customtkinter [way better styling in tkinter]
Make Tkinter Look 10x Better in 5 Minutes (CustomTkinter)
ALL Python Programmers Should Know This!!
PLEASE Learn These 10 Advanced Python Features




