
```
uv init my-project
cd my-project
```

---


创建虚拟环境

```
python -m venv .venv
```

激活虚拟环境

```
.venv/Scripts/activate
```

创建指定版本虚拟环境

```
py -3.13 -m venv .venv
```

生成 `requirements.txt`

```
pip freeze > requirements.txt
```

安装项目依赖

```
pip install -r requirements.txt
```

```
python -m venv .venv
.venv/Scripts/activate
pip freeze > requirements.txt
git init
git branch -m master main
curl https://raw.githubusercontent.com/github/gitignore/main/Python.gitignore -o .gitignore
```


打包为单文件
```
pyinstaller --onefile main.py
```

.gitignore

```
.gitignore
```

```
uvicorn main:app --reload
```

```
# Python
__pycache__/
*.py[cod]
*.pyo
*.pyd
*.db
*.sqlite3

# Flask
instance/
.webassets-cache

# IDEs
.vscode/
.idea/
*.swp

# Environment variables
.env
.venv/
venv/
env/
ENV/

# Jupyter Notebook
.ipynb_checkpoints

# Pytest
.cache
*.cover
*.log

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
#  Usually these files are written by a python script from a .spec file
*.manifest
*.spec

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# Coverage
.coverage
.coverage.*

```
