Python Installation
Detailed instructions on how to install Python on various operating systems.
Python Installation
Detailed instructions on how to install Python on various operating systems.
Package Management
Introduction to pip and virtual environments for dependency management.
Development Tools
Overview of popular IDEs, editors, and Git for a productive coding setup.
Before diving into Python coding, it’s essential to set up a proper development environment. This section guides you through the necessary steps, including installing Python, managing packages, and configuring your preferred tools.
The first step is to install Python on your machine. The installation process varies slightly depending on your operating system.
python --version
. You should see the installed Python version printed on the console.python3 --version
. If you have Python 2.7 installed by default, using python
command might give you Python 2.Linux systems may have Python pre-installed, but it’s often an older version. It’s recommended to install the latest version using your distribution’s package manager. Here are examples:
sudo apt update
.sudo apt install python3 python3-pip
.python3 --version
and pip3 --version
.sudo dnf update
.sudo dnf install python3 python3-pip
.python3 --version
and pip3 --version
.sudo pacman -S python python-pip
.python --version
and pip --version
.Python has a powerful package manager called pip
. It’s used to install and manage external libraries and dependencies needed for your projects.
To install a package, use the pip install
command followed by the package name. For example, to install the requests
library:
To verify the installation, you can list the installed packages with:
When working on multiple Python projects, each project might require different versions of packages. Using virtual environments isolates the dependencies of each project, preventing conflicts and dependency issues.
python3 -m venv venv
. This creates a directory named venv
(you can choose a different name if you wish) that contains the isolated python environment.Activate the environment:
Use the command source venv/bin/activate
in the terminal.
Use the command .\venv\Scripts\activate
in the Command Prompt.
You should now see the environment name (venv)
shown on the terminal line. Any packages you install with pip
will now be specific to this virtual environment.
4. To deactivate, use the deactivate
command in the terminal.
Choosing the right development environment can significantly improve your productivity. Here are some of the most popular IDEs and editors for Python development:
VS Code is a free, lightweight, and customizable code editor with a wide range of extensions. It is a great all-around option.
PyCharm is a powerful and specialized IDE designed for Python development. It offers intelligent code completion, debugging tools, and support for web frameworks.
pip install jupyterlab
.jupyter lab
in the terminal. This will open a browser window.Jupyter Notebook and JupyterLab are excellent for data analysis, visualization, and interactive development. It also allows to write and render markdown documents.
Other options include Sublime Text, Atom, and Vim. Choose the one that fits your workflow and preferences the best.
Git is a version control system that helps track changes in your code and collaborate with others. It is a very important tool that you should learn to use.
Download and install Git from the official website.
Configure git using the following commands in the terminal. These commands only need to be set once for each machine:
Initialize a new git repository within your project’s directory:
Add your files to staging using:
Commit your changes using:
(Optional) Create an account in Github or a similar git platform and create a new repository. Copy the git repository link and add it to your repository with:
Finally, push your repository to your remote repository:
It’s crucial to commit your changes regularly, use descriptive commit messages, and utilize branching for feature development.
Download Python
pip Documentation
VS Code Website
Official Git Website