-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-python-venv.sh
More file actions
executable file
·41 lines (28 loc) · 992 Bytes
/
create-python-venv.sh
File metadata and controls
executable file
·41 lines (28 loc) · 992 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# Define the Python version you want
PYTHON_VERSION="3.8" # Change this if you need a different version
# Check if Python is installed
if command -v python3 &>/dev/null; then
echo "Python is already installed."
else
echo "Python not found. Installing Python $PYTHON_VERSION..."
# Update package list and install Python
sudo apt-get update
sudo apt-get install -y python${PYTHON_VERSION} python${PYTHON_VERSION}-venv python${PYTHON_VERSION}-pip
fi
# Create a virtual environment
VENV_DIR="venv"
python3 -m venv ${VENV_DIR}
# Activate the virtual environment
source ${VENV_DIR}/bin/activate
# Upgrade pip in the virtual environment
pip install --upgrade pip
touch main.py
echo "venv/" >> .gitignore
echo "Setup complete. Virtual environment '${VENV_DIR}' created and basic packages installed."
if command -v code &> /dev/null; then
echo "Visual Studio Code is installed. Opening..."
code .
else
echo "Visual Studio Code not installed."
fi