Search code examples
pythonvisual-studio-codepyqgis

Visual Studio Code Upgrading to 1.56.0... Issues with Windows Environment


Prior to the last Visual Studio Code update, I was able to set the windows environment variables. Now with the new update I can't and I don't know what to do.

My code is quite long so to simplify it I have tried to change the windows prompt, something simple to see if I can find the solution.

{
    "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"
    }
}

the expected result is:

enter image description here

enter image description here


Solution

  • The solution was in this link:

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

    And in this paragraph the solution:

    Terminal profiles

    The terminal's shell defaults to $SHELL on Linux and macOS and PowerShell on Windows. Terminal profiles can be used to configure either the default or secondary shells by running the Terminal: Select Default Profile command, which is also accessible via the terminal's dropdown.

    VS Code will automatically present a set of common profiles for the dropdown and also detect less common ones which will only show up when selecting a default profile.

    Note: Several terminal settings won't work automatically when set in the workspace scope, you must grant them permission to run by setting the terminal.integrated.allowWorkspaceConfiguration setting to true in your user settings.

    What I do is, go to configuration, go to user configuration and i write:

    "terminal.integrated.allowWorkspaceConfiguration":true

    {
       
        "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
    }
    

    And now my code works again:

    {
        "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",
    }