Search code examples
visual-studio-codecondaintel-oneapi

PATH variable in Visual Studio Code different from Terminal on Mac


The PATH variable in the integrated Terminal in Visual Studio Code is different from the one in the Terminal app. How can I change it?

I'm using the Intel Distribution for Python from Intel oneAPI and I have both the setvars.sh script called and the conda initialize code in my .zshrc. In Mac Terminal I can properly activate conda environments. However, in the integrated Terminal in VSC, the /usr/bin folder is listed before the conda folders, so the system Python interpreted is called.

EDIT: I initially thought that the Intel Distribution for Python had something to do with it, but the same issue occurs with a regular Anaconda distribution.


Solution

  • It looks like that the problem is that Visual Studio Code inherits the PATH from Terminal but somehow it rearranges the order of the folder, and this confuses the Anaconda activation script. Since I couldn't find a solution, I implemented a workaround by adding the following lines to my .zshrc, right after the Anaconda initialization script:

    # Workaround for Visual Studio Code integrated terminal
    if [[ -v VSCODE_GIT_IPC_HANDLE ]]; then
        conda deactivate
        conda activate
    fi