环境配置
Content
色系

Prompt
翻译
### Role
You are a professional academic writing assistant and scientific translator with expertise in both English and Chinese. Your goal is to help researchers polish their manuscripts to meet the standards of top-tier academic conferences and journals (e.g., NeurIPS, ICLR, ICML, Nature, IEEE, ACM).
### Tasks & Instructions
- Whenever given a Chinese text wrapped within quotation marks (""), please provide the corresponding English translation.
- Whenever given an English text wrapped within quotation marks (""), please improve it to make it more academic, formal and neat.
- When a word or phrase wrapped within "[]" is given, please give some synonyms for that word or phrase.
### Examples
User: "近年来, 已经有许多相关方法被提出."
Assistant:
```latex
In recent years, a number of related methods have been proposed.
```
User: [a number of]
Assistant:
```latex
- numerous (adj. 众多的, 许多的): There are **numerous** methods in which to do this.
- many (adj. 许多的): **Many** scholars have argued thus.
```
User: [利用]
Assistant:
```latex
- use (v. 用, 使用, 利用): They **use** a lot of big words.
- employ (v. 使用, 采用, 雇佣): Many adversarial training methods **employ** the most adversarial data maximizing the loss for updating the current model.
- adopt (v. 采纳, 采取, 接受): There is little or no incentive to **adopt** such measures.
```
CC & Codex
## 常规准则
语言: 中文
标点符号: 英文
交互模式: 优先采用结构化、可选择的表单式交互; 表单中必须保留 `Type something` 的选项
风格语调: 专业可靠
## 代码准则
适用场景: 代码生成、代码审查
设计原则: 简洁高效, 优先使用成熟方案
注释语言: 英文
注释风格: NumPy-style
## 文档准则
适用场景: 笔记、文档、Slides
文字风格: 简练直白
VSCode
基本配置
{
// ==========================================
// 1. 编辑器基础设置 (General Editor)
// ==========================================
"editor.fontSize": 14,
"editor.lineNumbers": "on",
"editor.rulers": [],
"editor.accessibilitySupport": "off",
"editor.experimentalEditContextEnabled": false,
"files.autoSave": "afterDelay",
"update.mode": "manual",
"workbench.colorTheme": "Solarized-light",
"workbench.activityBar.location": "bottom",
"explorer.confirmDelete": false,
"explorer.confirmDragAndDrop": false,
"security.workspace.trust.untrustedFiles": "open",
"security.promptForLocalFileProtocolHandling": false,
"search.followSymlinks": false,
// ==========================================
// 2. 编程语言 & 语法高亮 (Languages & Theming)
// ==========================================
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "keyword.control.flow.python",
"settings": {
"foreground": "#FF6E6E",
"fontStyle": "bold"
}
},
{
"name": "Function/Method names",
"scope": [
"entity.name.function",
"meta.function-call.generic",
"support.function"
],
"settings": {
"foreground": "#FFAA5A"
}
}
]
},
"[python]": {
"editor.wordBasedSuggestions": "off"
},
// ==========================================
// 3. Vim 模拟器配置 (Vim Emulation)
// ==========================================
"vim.leader": ",",
"vim.easymotion": true,
"vim.incsearch": true,
"vim.useSystemClipboard": true,
"vim.useCtrlKeys": true,
"vim.hlsearch": true,
"vim.handleKeys": {
"<C-a>": false,
"<C-f>": false
},
// 插入模式快捷键 (jk 退出插入模式)
"vim.insertModeKeyBindings": [
{
"before": ["j", "k"],
"after": ["<Esc>"]
}
],
// 普通模式快捷键
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["<leader>", "d"],
"after": ["d", "d"]
},
{
"before": ["<C-n>"],
"commands": [":nohl"]
},
{
"before": ["E"],
"after": ["g", "t"]
},
{
"before": ["L"],
"after": ["$"]
},
{
"before": ["H"],
"after": ["^"]
}
],
"vim.normalModeKeyBindings": [
{
"before": ["Z", "Z"],
"commands": [":wq"]
}
],
// 可视模式快捷键
"vim.visualModeKeyBindings": [
{
"before": [">"],
"commands": ["editor.action.indentLines"]
},
{
"before": ["<"],
"commands": ["editor.action.outdentLines"]
}
],
"vim.visualModeKeyBindingsNonRecursive": [
{
"before": ["p"],
"after": ["p", "g", "v", "y"] // 粘贴后不丢失寄存器内容
}
],
// 算子模式
"vim.operatorPendingModeKeyBindings": [
{
"before": ["L"],
"after": ["$"]
},
{
"before": ["H"],
"after": ["^"]
}
],
// 自动切换输入法 (Mac im-select)
"vim.autoSwitchInputMethod.enable": true,
"vim.autoSwitchInputMethod.defaultIM": "com.apple.keylayout.ABC",
"vim.autoSwitchInputMethod.obtainIMCmd": "/usr/local/bin/im-select",
"vim.autoSwitchInputMethod.switchIMCmd": "/usr/local/bin/im-select {im}",
// ==========================================
// 4. LaTeX 配置 (Latex Workshop)
// ==========================================
"latex-workshop.latex.autoBuild.run": "never",
"latex-workshop.message.error.show": false,
"latex-workshop.message.warning.show": false,
"latex-workshop.showContextMenu": true,
"latex-workshop.intellisense.package.enabled": true,
"latex-workshop.view.pdf.internal.synctex.keybinding": "double-click",
// 编译工具配置
"latex-workshop.latex.tools": [
{
"name": "pdflatex",
"command": "pdflatex",
"args": ["-synctex=1", "-interaction=nonstopmode", "-file-line-error", "%DOCFILE%"]
},
{
"name": "xelatex",
"command": "xelatex",
"args": ["-synctex=1", "-interaction=nonstopmode", "-file-line-error", "%DOCFILE%"]
},
{
"name": "bibtex",
"command": "bibtex",
"args": ["%DOCFILE%"]
},
{
"name": "biber",
"command": "biber",
"args": ["%DOCFILE%"]
}
],
// 编译方案 (Recipe)
"latex-workshop.latex.recipes": [
{
"name": "pbibpp",
"tools": ["pdflatex", "bibtex", "pdflatex", "pdflatex"]
}
],
// 辅助文件清理
"latex-workshop.latex.clean.fileTypes": [
"*.aux", "*.bbl", "*.blg", "*.idx", "*.ind", "*.lof", "*.lot", "*.out", "*.toc", "*.acn", "*.acr", "*.alg", "*.glg", "*.glo", "*.gls", "*.ist", "*.fls", "*.log", "*.fdb_latexmk"
],
"latex-workshop.latex.autoClean.run": "onFailed",
// 外部 PDF 查看器 (SumatraPDF)
"latex-workshop.view.pdf.viewer": "external",
"latex-workshop.view.pdf.ref.viewer": "auto",
"latex-workshop.view.pdf.external.viewer.command": "E:/SumatraPDF/SumatraPDF.exe",
"latex-workshop.view.pdf.external.viewer.args": ["%PDF%"],
"latex-workshop.view.pdf.external.synctex.command": "E:/SumatraPDF/SumatraPDF.exe",
"latex-workshop.view.pdf.external.synctex.args": [
"-forward-search",
"%TEX%",
"%LINE%",
"-reuse-instance",
"-inverse-search",
"\"E:/Microsoft VS Code/Code.exe\" \"E:/Microsoft VS Code/resources/app/out/cli.js\" -r -g \"%f:%l\"",
"%PDF%"
],
// ==========================================
// 5. Jupyter Notebook & 数据科学 (Data Science)
// ==========================================
"notebook.lineNumbers": "on",
"notebook.confirmDeleteRunningCell": false,
"workbench.editorAssociations": {
"*.ipynb": "jupyter-notebook"
},
"jupyter.interactiveWindow.textEditor.executeSelection": false,
"jupyter.interactiveWindow.creationMode": "perFile",
// ==========================================
// 6. 远程开发 & 终端 (Remote SSH & Terminal)
// ==========================================
"terminal.integrated.enableMultiLinePasteWarning": "never",
"terminal.integrated.defaultProfile.windows": "Command Prompt",
// ==========================================
// 7. 版本控制 (Git)
// ==========================================
"git.confirmSync": false,
"git.autofetch": true,
"git.ignoreMissingGitWarning": true,
// ==========================================
// 8. Markdown & 图片托管 (Markdown & Assets)
// ==========================================
"markdown-preview-github-styles.colorTheme": "light",
"markdown-preview-enhanced.enablePreviewZenMode": false,
"pasteImage.path": "${currentFileDir}/${currentFileNameWithoutExt}",
"picgo.picBed.current": "github",
"picgo.picBed.github.repo": "MTandHJ/blog_source",
"picgo.picBed.uploader": "github",
"picgo.picBed.github.branch": "master",
"picgo.picBed.github.path": "images/",
// ==========================================
// 9. AI 辅助 (Copilot)
// ==========================================
"github.copilot.enable": {
"*": false,
"plaintext": false,
"markdown": false,
"scminput": false,
"python": false
}
}
Remote 免密登录
- 在远程服务器上执行如下命令 (
<id_rsa.pub>替换为个人的 .ssh 下的公钥):
cd ~
mkdir ./.ssh
echo "<id_rsa.pub>" >> ./.ssh/authorized_keys
chmod 600 ./.ssh/authorized_keys
chmod 700 ./.ssh
本地清理服务器 ssh 指纹
- 服务器重装系统后 ssh 指纹会发生更改, 此时需要通过如下命令删除
known_hosts
# windows 终端
ssh-keygen -R [服务器IP地址]
Latex
Windows
- MikTex:
- 设置 ‘Install missing packages’ 为 ‘Yes’.
Mac
- 该文件需通过
command + shift + p放入工作区设置 (即仅在当前目录下生效).
{
"latex-workshop.latex.tools": [
{
"name": "xelatex",
"command": "xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
},
{
"name": "pdflatex",
"command": "pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
},
{
"name": "latexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"%DOC%"
]
},
{
"name": "bibtex",
"command": "bibtex",
"args": [
"%DOCFILE%"
]
}
],
"latex-workshop.latex.recipes": [
{
"name": "XeLaTeX",
"tools": [
"xelatex"
]
},
// {
// "name": "PDFLaTeX",
// "tools": [
// "pdflatex"
// ]
// },
// {
// "name": "latexmk",
// "tools": [
// "latexmk"
// ]
// },
// {
// "name": "BibTeX",
// "tools": [
// "bibtex"
// ]
// },
{
"name": "xelatex -> bibtex -> xelatex*2",
"tools": [
"xelatex",
"bibtex",
"xelatex",
"xelatex"
]
},
// {
// "name": "pdflatex -> bibtex -> pdflatex*2",
// "tools": [
// "pdflatex",
// "bibtex",
// "pdflatex",
// "pdflatex"
// ]
// },
],
"latex-workshop.view.pdf.viewer": "external",
"latex-workshop.latex.autoBuild.run": "never",
"latex-workshop.view.pdf.external.synctex.command": "/Applications/Skim.app/Contents/SharedSupport/displayline",
"latex-workshop.view.pdf.external.synctex.args": [
"-r",
"%LINE%",
"%PDF%",
"%TEX%"
],
"latex-workshop.view.pdf.external.viewer.command": "/Applications/Skim.app/Contents/SharedSupport/displayline",
"latex-workshop.view.pdf.external.viewer.args": [
"0",
"%PDF%",
],
}
uv
uv 将 Python 解释器、全局工具和项目依赖分开管理:
- 全局 Python:任意目录执行
python。 - 全局工具:任意目录执行
ruff、ipython等命令。 - 项目环境:每个项目独立的
.venv、pyproject.toml与uv.lock。
全局环境设置 (类似于 conda 的 base 环境)
uv python install 3.11 --default
uv python update-shell
# 重新打开 PowerShell 后
python --version
uv pip install --python python numpy pandas
python -c "import numpy; print(numpy.__version__)"
uv tool install ruff
ruff --version
| 命令 | 介绍 | 备注 |
|---|---|---|
uv python install 3.11 --default |
安装 Python 3.11,并提供全局 python 命令 |
执行后重启终端或 VS Code. --default 会创建无版本号的 python |
uv python list |
查看本机可用和已安装的 Python 版本 | 用于确认 uv 管理的解释器 |
uv python find 3.11 |
查找 Python 3.11 的实际路径 | 排查解释器或 VS Code 配置时有用 |
uv python update-shell |
将 uv 的 Python/工具目录加入 Shell 的 Path | 执行后需要重新打开终端 |
uv pip install --python python numpy pandas |
将包安装到全局 python |
适合临时脚本;不建议安装正式项目依赖 |
uv pip list --python python |
查看全局 Python 已安装的包 | --python python 明确指定全局解释器 |
uv pip install --python python --upgrade numpy |
升级全局 Python 中的包 | 升级可能影响依赖该包的临时脚本 |
uv tool install ruff |
全局安装命令行工具 | 适合 ruff、black、ipython、jupyterlab 等 CLI |
uv tool list |
查看已安装的全局工具 | 每个工具使用独立环境,不污染全局 Python |
uv tool upgrade --all |
升级全部全局工具 | 等价于集中更新常用 CLI |
uv tool uninstall ruff |
卸载一个全局工具 | 只删除该工具,不影响其他环境 |
uvx ruff check . |
临时运行一个工具 | 不需要预先安装;适合偶尔使用的 CLI |
2. 项目管理
项目环境应由 uv 自动维护,不依赖全局包。每个项目通常包含:
project/
├── pyproject.toml # 项目依赖与配置
├── uv.lock # 精确锁定的依赖版本
└── .venv/ # 项目独立虚拟环境
- (从零创建新项目)
mkdir E:\Desktop\demo
cd E:\Desktop\demo
uv init
uv add requests
uv add --dev pytest ruff
uv run python -c "import requests; print(requests.__version__)"
uv run ruff check .
uv tree
- (接管旧项目)
cd E:\Desktop\some-project
uv sync
uv run python main.py
uv run pytest
| 命令 | 介绍 | 备注 |
|---|---|---|
uv init |
初始化一个新的 Python 项目 | 创建 pyproject.toml、README 与基础目录. 已有 pyproject.toml 的项目不需要执行 |
uv init --bare |
初始化最简项目 | 只创建必要的项目配置, 适合脚本项目 |
uv add requests |
添加项目依赖 | 自动更新 pyproject.toml 和 uv.lock |
uv add "numpy==2.2.0" |
添加指定版本依赖 | 可使用 ==、>= 等版本约束 |
uv add --dev pytest ruff |
添加开发依赖 | 适合测试、格式化、Lint 工具 |
uv remove requests |
删除项目依赖 | 同时更新锁文件 |
uv sync |
创建或同步项目 .venv |
克隆项目后首先执行; 按 uv.lock 安装依赖 |
uv run python main.py |
在项目环境中运行脚本 | 推荐方式; 无需手动激活 .venv |
uv run pytest |
在项目环境中运行命令 | 自动使用项目安装的测试工具 |
uv tree |
查看项目依赖树 | 排查间接依赖和版本来源 |
uv lock |
更新锁文件 | 通常 uv add 后会自动处理 |
uv lock --upgrade |
升级锁文件中的依赖版本 | 之后执行 uv sync 安装新版本 |
uv run --with rich python demo.py |
临时为一次运行添加依赖 | 不修改 pyproject.toml 和 uv.lock |
Conda
- 下载后通过如下命令安装
bash Miniconda3-latest-Linux-x86_64.sh
清华镜像
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/linux-64/
conda config --set show_channel_urls yes
Pip
清华镜像
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
WSL
-
(安装) 在 powershell 中通过
wsl --install进行安装.
-
(本地代理) 通过 “WSL Settings” 中开启 “已启用自动代理”, “已启用 DNS 代理”, 如有必要进一步关闭 “已启用 Hyper-V 防火墙”.