This script automates the creation of new Python project folders with:
- A virtual environment (
venv) - Git repository initialization
- Pre-configured
.gitignore - VS Code settings to auto-select the venv
- VS Code terminal that launches with the venv activated and prompt customized
- Optional
.activate.txtand.gitignore.txtappend support - Auto-installation of the VS Code Python extension
When you run the script, it creates a structure like:
When you run the script, it creates a structure like:
/opt/python/<project_name>/
├── venv/
├── main.py
├── .gitignore
├── .vscode/
│ ├── settings.json ← from settings.json.txt
│ └── tasks.json ← from tasks.json.txt
From terminal:
python3 make_new_project.py
You'll be prompted to enter a new project name. The script will then:
- Create the project folder under /opt/python/
- Set up a venv
- Create main.py
- Apply .gitignore, settings.json, and tasks.json templates
- Open the project in VS Code
Make sure these template files are in the same directory as the script:
- gitignore.txt → used for .gitignore
- settings.json.txt → VS Code interpreter + terminal profile
- tasks.json.txt → custom task to open a terminal with venv activated
- activate.txt (optional) → custom lines appended to venv/bin/activate
Open a new terminal in VS Code, then run:
which python
It should return something like:
/opt/python/project_name/venv/bin/python
Your prompt should also begin with (venv) if configured correctly.
- Python 3.6+
- VS Code installed and accessible via
code - VS Code Python extension (auto-installed by the script)
MIT License