Welcome! This guide will help you get started with Python, set up your own workspace in the project, and understand how to work with virtual environments (venv) and Git.
Python is easy to read if you know English which makes it pretty non-intimidating and beginner-friendly. Key features include:
- Easy-to-learn syntax.
- Large standard library for various tasks.
- Extensive community support and third-party libraries.
To get the repository on your computer you must clone it from Github. Git and Github are not the same! Git is a program installed on your computer that manages repositories. Github is just a place where they are stored.
Be aware that this will create a new folder named python-learning inside the folder your terminal is at. If you aren't comfortable with the terminal, you can go into a folder using the regular Windows file explorer and type cmd on the address bar at the top. This will open a console on that folder.
git clone https://github.com/xarop-pa-toss/python-learningAfter cloning the repository, navigate to the dev folder. The cd command stands for 'Change Directory':
cd python-learning/devCreate a folder with your name to organize your programs. Try to not use spaces in your folders and file names. Separate with either - or _
mkdir your-name
cd your-nameWelcome to your own folder! This is where you will create subfolders for each project. For example, to create a folder for a calculator project:
mkdir your-name/calculator
cd your-name/calculatorA virtual environment (venv) is a tool that helps manage dependencies for your Python projects. It creates an isolated Python environment for each project, ensuring that library versions don’t conflict between projects. Initialize a virtual environment inside the folder:
python -m venv venvActivate the virtual environment:
- On Windows:
.venv\Scripts\activate
- On macOS/Linux:
source venv/bin/activate
When you open the project folder in VSCode, it will automatically detect the virtual environment and use it for running your code. Ensure the Python extension is installed in VSCode to take full advantage of this feature.
If you are ever in the command line inside a folder and want to open it in VSCode, you can just type
code .code is the command for VSCode and . is the shortcut for "current folder". Basically opening the current folder in VSCode :)
After you have made your folder, subfolder and created your Venv (which creates a .venv folder), your file explorer inside VSCode should have a structure kinda like this.
├── dev/
│ ├── your-name/
│ │ ├── calculator/
│ │ │ ├── venv/ # Virtual environment folder
│ │ │ ├── your_python_files.py
│ │ └── another-project/ # Example of another project folder
│ │ ├── venv/ # Virtual environment folder
│ │ ├── project_code.py
Your code only exists on your computer though, so to keep it safe and traceable, you have to push it to the repo using Git. You can use VSCode's visual interface for Git, a button on the sidebar called Source Control which should tell you that there are changes to Commit. Add a short message that explains the changes you made, eg. "Create user folder and initialize project Calculator" or something else that feels right and press Commit and then Sync (it pulls changes from the repo and then pushes your own).