Skip to content

Instantly share code, notes, and snippets.

@sovietspy2
Created November 12, 2023 14:34
Show Gist options
  • Save sovietspy2/f69ec25cff4c774a0ec2b536333cf746 to your computer and use it in GitHub Desktop.
Save sovietspy2/f69ec25cff4c774a0ec2b536333cf746 to your computer and use it in GitHub Desktop.
create venv in current directory or activate venv is present
#!/bin/bash
# Define the name for the virtual environment
venv_name="venv"
# Check if the virtual environment already exists
if [ -d "$venv_name" ]; then
echo "Activating existing virtual environment..."
source "$venv_name/bin/activate"
else
echo "Creating and activating a new virtual environment..."
python3 -m venv "$venv_name"
source "$venv_name/bin/activate"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment