Skip to main content
benhall / flask-demo
About Waitlist Learn Search Enterprise
Search
Login Sign Up
Logo
Main Menu Project Homepage Learn Codebase Developer Dashboards Contribute Extensions Help
  • Learn Codebase
  • Learn API
  • Learn SDK
  • Environment Setup
  • Knowledge Base
  • Chat to Codebase
  • Search
Logo Shoulder Homepage
Project Homepage
Learn Codebase
Developer Dashboards
Contribute
Extensions
Help
  • Development
  • Setup
  • Docker Configuration
  • Start & Build
  • Run Tests
  • Configuration
  • Common Issues
  • CI/CD
  • Workflow
  • Automation scripts
  • Deploy
  • Production
  • Deployment
  • Secret Management
  • Monitoring & Logging
  • Scaling & Performance
  • Contributor Dashboards
Cloud Setup Windows Setup MacOS Setup Linux Setup Docker Setup VS Code Setup Terminal

Installing Python on Windows and Windows Subsystem for Linux (WSL)

This guide will help you install Python on both Windows and Windows Subsystem for Linux (WSL). Follow the steps below for a smooth installation process.

Installing Python on Windows

  1. Download the Python Installer:
  • Go to the Python Downloads page.
  • Click on the “Download Python” button. This will download the latest version of Python.
  1. Run the Installer:
  • Locate the downloaded installer file (usually in the Downloads folder).
  • Double-click the installer to run it.
  1. Customize Installation (Optional):
  • Check the box that says “Add Python to PATH”.
  • Click on “Customize installation” if you want to choose optional features, otherwise, click “Install Now”.
  1. Complete Installation:
  • Follow the prompts and wait for the installation to complete.
  • Once the installation is complete, click “Close”.
  1. Verify Installation:
  • Open Command Prompt.
  • Type python --version and press Enter.
  • You should see the version of Python that you installed.

Installing Python on Windows Subsystem for Linux (WSL)

  1. Install WSL:
  • Open PowerShell as Administrator.
  • Run the command:
wsl --install
  • Restart your computer if prompted.
  1. Set Up WSL:
  • After restarting, open PowerShell again and run:
wsl --set-default-version 2
  • Install your preferred Linux distribution from the Microsoft Store (e.g., Ubuntu).
  1. Launch WSL:
  • Open your installed Linux distribution (e.g., Ubuntu) from the Start menu.
  • Follow the on-screen instructions to complete the initial setup.
  1. Update Package List:
  • In the WSL terminal, run:
sudo apt update
  1. Install Python:
  • To install Python 3, run:
sudo apt install python3
  • Optionally, install pip (Python package installer):
sudo apt install python3-pip
  1. Verify Installation:
  • In the WSL terminal, type python3 --version and press Enter.
  • You should see the version of Python that you installed.

By following these steps, you will have Python installed on both Windows and WSL, allowing you to run Python scripts in both environments.

Installing Python on macOS

This guide will help you install Python on macOS. Follow the steps below for a smooth installation process.

Installing Python on macOS

  1. Check the Pre-installed Python:
  • macOS usually comes with Python 2.x pre-installed. To check, open Terminal and type:
python --version
  • To check for Python 3.x, type:
python3 --version
  1. Install Homebrew (if not already installed):
  • Homebrew is a popular package manager for macOS. To install Homebrew, open Terminal and paste the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  1. Install Python using Homebrew:
  • Once Homebrew is installed, you can use it to install Python 3. Run the following command in Terminal:
brew install python
  • This command will install the latest version of Python 3 and pip (Python package installer).
  1. Verify Installation:
  • To verify that Python 3 is installed, type:
python3 --version
  • To verify that pip is installed, type:
pip3 --version
  1. Set Up PATH (if necessary):
  • Homebrew usually sets up the PATH for you. However, if you need to manually set it up, add the following line to your ~/.zshrc or ~/.bash_profile (depending on your shell):
export PATH="/usr/local/opt/python/libexec/bin:$PATH"
  • Reload the shell configuration by running:
source ~/.zshrc   # for Zsh users
source ~/.bash_profile   # for Bash users
  1. Install Virtualenv (Optional but recommended):
  • Virtualenv helps you create isolated Python environments. To install it, run:
pip3 install virtualenv

By following these steps, you will have Python installed on macOS, ready for running your Python scripts and projects.

Installing Python on Linux

This guide will help you install Python on various Linux distributions. Follow the steps below for a smooth installation process.

Installing Python on Ubuntu/Debian-based Distributions

  1. Update Package List:
  • Open Terminal and run:
sudo apt update
  1. Install Python:
  • To install Python 3 and pip (Python package installer), run:
sudo apt install python3 python3-pip
  1. Verify Installation:
  • To verify that Python 3 is installed, type:
python3 --version
  • To verify that pip is installed, type:
pip3 --version

Installing Python on Fedora/RHEL-based Distributions

  1. Update Package List:
  • Open Terminal and run:
sudo dnf update
  1. Install Python:
  • To install Python 3 and pip, run:
sudo dnf install python3 python3-pip
  1. Verify Installation:
  • To verify that Python 3 is installed, type:
python3 --version
  • To verify that pip is installed, type:
pip3 --version

Installing Python on Arch Linux

  1. Update Package List:
  • Open Terminal and run:
sudo pacman -Syu
  1. Install Python:
  • To install Python 3 and pip, run:
sudo pacman -S python python-pip
  1. Verify Installation:
  • To verify that Python 3 is installed, type:
python --version
  • To verify that pip is installed, type:
pip --version

Creating a Virtual Environment (Optional but recommended)

  1. Install Virtualenv:
  • To install Virtualenv, run:
pip3 install virtualenv
  1. Create a Virtual Environment:
  • Navigate to your project directory:
cd /path/to/your/project
  • Create a virtual environment:
python3 -m venv venv
  1. Activate the Virtual Environment:
  • To activate the virtual environment, run:
source venv/bin/activate
  • To deactivate the virtual environment, simply run:
deactivate

By following these steps, you will have Python installed on your Linux distribution, ready for running your Python scripts and projects.

Installing Python in a Docker Container

This guide will help you set up a Docker container with Python installed. Follow the steps below for a smooth installation process.

Prerequisites

  1. Install Docker:
  • Follow the instructions on the Docker installation page to install Docker for your operating system.
  1. Verify Docker Installation:
  • Open a terminal and run:
docker --version
  • You should see the Docker version installed on your machine.

Creating a Docker Container with Python

Using a Dockerfile

  1. Create a Project Directory:
  • Create a new directory for your project and navigate to it:
mkdir my-python-app
cd my-python-app
  1. Create a Dockerfile:
  • Create a file named Dockerfile in your project directory with the following content:
# Use the official Python image from the Docker Hub
FROM python:3.9

# Set the working directory in the container
WORKDIR /usr/src/app

# Copy the current directory contents into the container at /usr/src/app
COPY . .

# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# Make port 80 available to the world outside this container
EXPOSE 80

# Define environment variable
ENV NAME World

# Run app.py when the container launches
CMD ["python", "app.py"]
  1. Create a requirements.txt File:
  • If your application has dependencies, list them in a requirements.txt file in your project directory:
flask
requests
  1. Create a Simple Python Application:
  • Create a file named app.py in your project directory with a simple Python application:
from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello():
return "Hello World!"

if __name__ == '__main__':
app.run(host='0.0.0.0', port=80)
  1. Build the Docker Image:
  • In your project directory, run:
docker build -t my-python-app .
  1. Run the Docker Container:
  • Once the image is built, run a container based on the image:
docker run -p 4000:80 my-python-app
  • Your application will be accessible at http://localhost:4000.

Using a Docker Compose File

  1. Create a docker-compose.yml File:
  • Create a docker-compose.yml file in your project directory with the following content:
version: '3'
services:
web:
image: python:3.9
working_dir: /usr/src/app
volumes:
- .:/usr/src/app
ports:
- "4000:80"
command: python app.py
  1. Run Docker Compose:
  • In your project directory, run:
docker-compose up
  • Your application will be accessible at http://localhost:4000.

By following these steps, you will have a Docker container running with Python installed, ready for running your Python applications.

VS Code Environment

When using VS Code we recommend installing the following extensions:

ms-vscode.makefile-tools

Extension for Visual Studio Code.

 screenshot

ms-python.python

Extension for Visual Studio Code.

 screenshot

Docker

Makes it easy to create, manage, and debug containerized applications.

 screenshot

CLI Tooling

The tooling CLI tooling would be beneficial to have setup:

Makefile

More details coming soon

Cloud based Development Environments

No cloud-based development environments are available for this project, however use the links below to quickly launch a new environment.

Gitpod

Open in Gitpod

GitHub Codespaces

Open in GitHub Codespaces

VS Code

Open in VS Code (Web)
Shoulder.dev can make mistakes.Consider checking important information.