0xNixxy Tech Tips

Python Quickstart Guide

Python is one of the easiest scripting languages to learn. However, setting up a proper development environment for Python can be confusing due to the long history of fragmented tools, virtual environments, and legacy packaging systems. This quickstart is designed for both first-time learners and experienced developers who just need a fuss-free way to set up Python to start coding.

This opinionated guide focuses on a mainstream Python workflow on Linux, which includes tools, commands, and conventions widely recommended in 2026, while briefly covering older approaches that you can safely skip over.

Useful Background Knowledge

  1. Use Python 3 for your new projects.

    • Python 2 is obsolete and deprecated since 2020.

    • Use the newest stable version of Python that has a reasonable End-of-Life (EOL) timeline for your use case. Refer to the status of Python versions on EOL information.

  2. As Python often comes pre-installed with Linux, Linux is generally easier (than Windows) to setup Python.

    • For Ubuntu 24.04, use the following commands to setup Python3

       sudo apt update
       sudo apt install python3 python-is-python3
      

      💡 Tip

      Installing Python, as described above, limits you to the “latest” version supported by the system, which may not be updated to the latest version of Python. Developers generally prefer to use the uv version management tool, which allows them to deploy specific Python versions for each project. If you are starting on Python, I recommend using the uv tool to set up Python.

    • For Windows, download the installer from the official Python website to install Python.

  3. The uv version management tool comes with a ruff linting and formatting tool for Python source code. Linters help you catch mistakes early in your source code and help build good coding habits in developers. Using a common formatting tool simplifies source code readability and maintenance among developers working on the same project.

Set up specific Python versions with uv

The instruction below guides you on how to install Python using uv on Ubuntu 24.04:

  1. [Optional prerequisites] Ensure that your system has the following tools installed to proceed with the subsequent steps.

    sudo apt install curl
    
  2. Install latest version of uv using the official stand-alone installer.

    curl -LsSf --tlsv1.3 https://astral.sh/uv/install.sh | sh
    

    💡 Tip

    To upgrade uv, use the uv self update command.

    To uninstall uv, use the following commands

    uv cache clean
    rm -r "$(uv python dir)"
    rm -r "$(uv tool dir)"
    
  3. Restart your shell to activate uv environment settings.

  4. Use the following command to validate that uv has been properly installed. You should see the version number printed to terminal.

    uv self version
    
  5. Install a specific version of Python.

    uv python install 3.13
    

    💡 Tip

    To upgrade a specific Python version to the latest patch release, use uv python upgrade 3.13.

  6. Check that Python was installed properly.

    uv python list
    
  7. Set a project to use a specific version of Python.

    mkdir hello-world
    cd hello-world
    uv python pin 3.13
    

    💡 Tip

    To set a global default version of Python in your user account, use uv python pin --global 3.13.

  8. Check the version of Python executed by uv in the project.

    uv run python --version
    

Run Python scripts with uv

Once you have set up the target Python version with uv above, you can run Python scripts in the following ways

  1. Run script without 3rd-party dependencies.

    uv run hello-world.py
    

    ℹ️ Note

    Usage of modules from the Python standard libraries is supported in this mode of running Python scripts.

  2. Run script with 3rd-party dependencies (ideally within a project).

    1. Create a new Python project with uv.

      mkdir hello-world
      cd hello-world
      uv init
      
    2. Run the Python project.

      uv run main.py
      

💡 Tip

For more information on working on projects with uv, read the official documentation.

Lint your Python project with ruff

To use a linter to check your Python source code in a project, follow the steps below

  1. (One-time setup) Install latest version of ruff globally.

    uv tool install ruff@latest
    
  2. Format code style for all Python source files in current directory.

    ruff format
    
  3. Lint (check) all Python source files in current directory.

    ruff check
    

Gradual deprecation of older Python tools

Python developers are rapidly consolidating around the new generation of tools, such as uv and ruff, which are designed to replace the older fragmented toolchain. However, many active Python projects have yet to migrate to the new toolchains and will likely take a few years for the entire Python ecosystem to complete migration.

New and experienced developers will need to recognise these older tools when there is a need to integrate the new toolchain with older Python projects. The following table summarises the list of old tools and the superseding new tools.

Old Tool Purpose Equivalent New Tool
pyenv Version manager for Python uv python install
pip Install packages uv add
python -m venv Create virtual environments uv
pipenv Package + env management uv
poetry Dependency management uv
requirements.txt List dependencies used by pip uv uses pyproject.toml
flake8 / pylint Linting ruff check
black Formatting ruff format
virtualenv Older venv tool Obsolete since Python 3.3
conda Python + non-Python packages Only needed for scientific stacks

Back to Main Page