vscode设置pycharm中的项目路径和debug方法

  1. 命令行运行:
    export PYTHONPATH=:pwd:/home/bennie/bennie/bennie_project/AI_Lab
    python main.py
    当关闭此命令行时,临时路径会清除,可以将上述export的整条语句,加入~/.bashrc中
    该命令中,以:分隔两个不同的路径

debug

vsocde的debug需要设置launch.json,字段中env是重要的

json 复制代码
{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Build_Seg_Model",
            "type": "python",
            "request": "launch",
            "program": "/home/T/T/T/AI_Lab/seg_module/Segment_Lab/BuildSegModel.py",
            "console": "integratedTerminal",
            "justMyCode": false,
            "env": {
                "PYTHONPATH": "${workspaceRoot}"
            },
        }
    ]
}

当设置为这样的pythonpath后,所有的导入都可以从项目目录开始import

相关推荐
weixin_402278451 天前
解决打开vscode编辑器ctrl+鼠标左键不能跳转定义问题 环境C++
vscode·编辑器·计算机外设
qq_589568101 天前
java学习笔记,包括idea快捷键
java·ide·intellij-idea
一次旅行1 天前
IDEA安装CC GUI新手指南
java·ide·intellij-idea
程序设计实验室1 天前
Zed AI 白嫖免费模型,搭配 DeepSeek v4,玩转 Agent 编程技巧
ide
-星空下无敌2 天前
IDEA 2025.3.1最新最全下载、安装、配置及使用教程(保姆级教程)
java·ide·intellij-idea
Gene_20222 天前
ubuntu22.04安装Claude Code及其在vscode跑通
ide·vscode·arcgis
isaac.easy2 天前
实战指南:CodeBuddy IDE × GLM-4.7 × Spec-Kit 构建智能化开发工作流
ide
shuangrenlong2 天前
android studio突然一直importing卡住
android·ide·android studio
想躺平的小羊2 天前
IDEA 如何显示或关闭项目类的结构(类的方法)
java·ide·intellij-idea