Wissensdatenbank

How to Install Python and Set Up a Virtual Environment

Python is a versatile language for automation, web apps and data. Ubuntu ships with Python 3; here’s how to set up an isolated project environment.

1. Verify Python and install tooling

python3 --version
sudo apt update
sudo apt install -y python3-pip python3-venv

2. Create a virtual environment

mkdir myproject && cd myproject
python3 -m venv venv
source venv/bin/activate

Your prompt now shows (venv). Packages you install stay isolated to this project.

3. Install packages

pip install requests flask
pip freeze > requirements.txt

4. Deactivate when done

deactivate

Recreate the environment elsewhere with pip install -r requirements.txt.

War diese Antwort hilfreich?

0 Benutzer fanden dies hilfreich

Powered by WHMCompleteSolution