Ubuntu

Python on Ubuntu: Step by Step

Learn to set up and develop Python applications in Ubuntu with this interactive guide

Get Started with Python Development

1. Install Python

Ubuntu ships with Python pre-installed. For development:

sudo apt update && sudo apt install python3-pip

Verify installation: python3 --version

2. Create Virtual Environment

python3 -m venv myenv
source myenv/bin/activate

Exit virtual env: deactivate

3. First Python Program

# hello.py
print("Hello from Ubuntu!")

Run: python3 hello.py

4. Package Management

pip install --upgrade pip
pip install numpy pandas

Freeze dependencies: pip freeze > requirements.txt

Common Issues

UnicodeDecodeError

Try setting encoding explicitly:

PYTHONIOENCODING=utf-8 python3 script.py
ModuleNotFoundError

Different environments: Check with

which python3
which pip3

Next Steps

Want to contribute? Fork our documentation repo on GitHub