User Tools

Site Tools


python_virtual_environment_recipe

Python virtual environment recipe

Note: On Ubuntu, you may need to install the python3-venv package first.

Create a setup.sh script:

#!/bin/bash

# Create virtual environment
python3 -m venv myenv

# Activate virtual environment
source myenv/bin/activate

# Upgrade pip
pip install --upgrade pip

# Install dependencies
pip install -r requirements.txt

Create a requirements.txt file:

# List your project dependencies here
package_name1
package_name2

To prepare or activate:

./setup.sh

To deactivate the virtual environment:

deactivate
python_virtual_environment_recipe.txt · Last modified: 2024/07/09 07:34 by tkbletsc

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki