Search code examples
tensorboard

Failed to start a TensorBoard session in vscode due to the following error:


To launch tensorboard in vscode, I did the following steps:

  1. select a python interpreter path
  2. choose Python:Launch TensorBoard

and then I get this error:

We failed to start a TensorBoard session due to the following error: Command failed: conda activate ldl && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python /home/cxy/.vscode-server/extensions/ms-python.python-2022.18.2/pythonFiles/printEnvVariables.py

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
If your shell is Bash or a Bourne variant, enable conda for the current user with

    $ echo ". /home/cxy/anaconda3/etc/profile.d/conda.sh" >> ~/.bashrc

or, for all users, enable conda with

    $ sudo ln -s /home/cxy/anaconda3/etc/profile.d/conda.sh /etc/profile.d/conda.sh

The options above will permanently enable the 'conda' command, but they do NOT
put conda's base (root) environment on PATH.  To do so, run

    $ conda activate

in your terminal, or to put the base environment on PATH permanently, run

    $ echo "conda activate" >> ~/.bashrc

Previous to conda 4.4, the recommended way to activate conda was to modify PATH in
your ~/.bashrc file.  You should manually remove the line that looks like

    export PATH="/home/cxy/anaconda3/bin:$PATH"

^^^ The above line should NO LONGER be in your ~/.bashrc file! ^^^


I have tried the suggested command, which is echo ". /home/cxy/anaconda3/etc/profile.d/conda.sh" >> ~/.bashrc but it doesn't work, I still get the same error.

How can I solve this problem? Is there any suggestion? thanks in advance!!!


Solution

  • I have solved this problem!!!

    Basically, it is caused by the latest version of Python and Pylance extension in vscode, all we have to do is simply downgrade the two extensiona and make sure vscode won't update them automatically.

    So, do the following:

    1. Downgrade Python extension and Pylance extension to eariler version, like v2021.10.xx and v2021.10.0 respectively.

    2. Close the extension auto update in vscode, to ensure the downgradion in step1 works after restarting vscode.

      Specifically, openSettings and search for the keyword update, do the following:

      2.1. beneath the Update: Mode,select None instead of default

      2.2. beneath the Extensions: Auto Update, select None instead of All extensions


    After I did the above steps, the problem just disappeared. I can then launch tensorboard by shift+cmd+P and select Python:Launch TensorBoard.