0

在上次 Visual Studio Code 更新之前,我能够设置 windows 环境变量。现在有了新的更新,我不能也不知道该怎么办。

我的代码很长,所以为了简化它,我尝试更改 windows 提示符,看看我是否能找到解决方案。

{
    "folders": [],
    "settings": {
        "terminal.integrated.profiles.windows": {

            "PowerShell": {
                "source": "PowerShell",
                "icon": "terminal-powershell",
            },
            "Command Prompt": {
                "source": "Command Prompt",
                "path": [
                    "${env:windir}\\Sysnative\\cmd.exe",
                    "${env:windir}\\System32\\cmd.exe"
                ],
                "args": [],
                "icon": "star",
                
            },
            "Git Bash": {
                "source": "Git Bash"
            }
        },
        "terminal.integrated.env.windows": {
            "ENV_PROMPT":"(env_qgis)",
            "PROMPT": "(Entorno Qgis) $P$G"
        },
        "terminal.integrated.defaultProfile.windows": "Command Prompt"
    }
}

预期结果是:

在此处输入图像描述

在此处输入图像描述

4

1 回答 1

0

解决方案在此链接中:

https://code.visualstudio.com/docs/editor/integrated-terminal

在本段中,解决方案:

终端配置文件

终端的 shell 在 Linux 和 macOS 上默认为 $SHELL,在 Windows 上默认为 PowerShell。终端配置文件可用于通过运行终端配置默认或辅助 shell:选择默认配置文件命令,该命令也可通过终端的下拉菜单访问。

VS Code 将自动为下拉列表显示一组常用配置文件,并检测仅在选择默认配置文件时才会显示的不太常见的配置文件。

注意:一些终端设置在工作区范围内设置时不会自动运行,您必须通过在用户设置中将 terminal.integrated.allowWorkspaceConfiguration 设置设置为 true 来授予它们运行权限。

我要做的是,去配置,去用户配置,然后我写:

“terminal.integrated.allowWorkspaceConfiguration”:真

{
   
    "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
    "python.languageServer": "Pylance",
    "workbench.activityBar.visible": true,
    "window.zoomLevel": -1,
    "terminal.integrated.tabs.enabled": true,
    "terminal.integrated.allowWorkspaceConfiguration":true
}

现在我的代码又可以工作了:

{
    "folders": [
        {
            "name": "Program",
            "path": ".."
        },
        
    ],
    "settings": {
        "python.autoComplete.extraPaths": ["C:/Roberto/Visual_Studio_Code/GisBike/programa;C:\\OSGeo4W64\\apps\\qgis\\python;C:\\OSGeo4W64\\apps\\Python37;C:\\OSGeo4W64\\apps\\Python37\\Scripts"],
        "python.pythonPath": "C:\\OSGeo4W64\\apps\\Python37\\python.exe",
        //"python.pythonPath": "C:\\Users\\Fcc\\Desktop\\vs_qs.bat",
        //"python.pythonPath": "C:\\Program Files\\QGIS 3.12\\apps\\Python37\\python.exe",
        "editor.fontSize": 18,
        "editor.wordWrap": "on",
        "editor.wordWrapColumn": 60,

        "terminal.integrated.env.windows": {

            // GDAL
            "GDAL_DATA": "C:\\OSGeo4W64\\share\\gdal",
            "GDAL_DRIVER_PATH": "C:\\OSGeo4W64\\bin\\gdalplugins",
            "GDAL_FILENAME_IS_UTF8": "YES",
            // GeoTIFF
            "GEOTIFF_CSV": "C:\\OSGeo4W64\\share\\epsg_csv",
            // Qt
            "O4W_QT_BINARIES": "C:/OSGeo4W64/apps/Qt5/bin",
            "O4W_QT_DOC": "C:/OSGeo4W64/apps/Qt5/doc",
            "O4W_QT_HEADERS": "C:/OSGeo4W64/apps/Qt5/include",
            "O4W_QT_LIBRARIES": "C:/OSGeo4W64/apps/Qt5/lib",
            "O4W_QT_PLUGINS": "C:/OSGeo4W64/apps/Qt5/plugins",
            "O4W_QT_PREFIX": "C:/OSGeo4W64/apps/Qt5",
            "O4W_QT_TRANSLATIONS": "C:/OSGeo4W64/apps/Qt5/translationss",
            "QT_PLUGIN_PATH": "C:\\OSGeo4W64\\apps\\qgis\\qtplugins;C:\\OSGeo4W64\\apps\\qt5\\plugins",
            "PROJ_LIB":"C:\\OSGeo4W64\\share\\proj",
            // QGIS
            "OSGEO4W_ROOT": "C:\\OSGeo4W64",
            "QGIS_PREFIX_PATH": "C:/OSGeo4W64/apps/qgis",
            // Cache
            "VSI_CACHE": "TRUE",
            "VSI_CACHE_SIZE": "1000000",
            "JPEGMEM":"1000000",
            // Virtual Envoirment
            "VIRTUAL_ENV": "C:\\Program Files\\Python38\\env_qgis",
            "ENV_PROMPT":"(env_qgis)",
            "PROMPT": "(Entorno Qgis) $P$G",

            // Path
            "PATH": "C:\\OSGeo4W64\\apps\\qgis\\bin;C:\\OSGeo4W64\\apps\\qgis\\bin;C:\\OSGeo4W64\\apps\\Python37;C:\\OSGeo4W64\\apps\\Python37\\Scripts;C:\\OSGeo4W64\\apps\\qt5\\bin;C:\\OSGeo4W64\\bin;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\system32\\WBem;C:\\Users\\Fcc\\AppData\\Roaming\\Python\\Python37\\Scripts;C:\\Program Files\\Exiftool;C:\\Program Files\\ffmpeg\\bin",

            // Python
            "PYTHONHOME": "C:\\OSGeo4W64\\apps\\Python37",
            "PYTHONPATH":"C:\\OSGeo4W64\\apps\\qgis\\python;C:\\OSGeo4W64\\apps\\Python37;C:\\OSGeo4W64\\apps\\Python37\\Scripts"

        },
        "git.ignoreLimitWarning": true,
        "terminal.integrated.cwd": "C:\\Roberto\\Visual_Studio_Code\\GisBike\\programa",
        "editor.minimap.enabled": false,
        "python.analysis.extraPaths": [
            "C:/Roberto/Visual_Studio_Code/GisBike/programa;C:\\OSGeo4W64\\apps\\qgis\\python;C:\\OSGeo4W64\\apps\\Python37;C:\\OSGeo4W64\\apps\\Python37\\Scripts"
        ]
    },
    "emmet.extensionsPath": "",
    "terminal.integrated.automationShell.windows": "cmd",
}
于 2021-05-12T16:50:09.287 回答