VSCode Tensorboard (via Python extension) doesn't run in WSL2 - visual-studio-code

When I work with VSCode inside WSL2 and run the Python: Launch Tensorboard command, it first asks
The package TensorBoard is required to launch a TensorBoard session. Would you like to install it?
Source: Python (Extension)
When I click Yes, it says
Could not install tensorboard. If pip is not available, please use the package manager of your choice to manually install this library into your Python environment.
But what environment is that? I can run my python scripts and notebooks without problem. I typically use Miniconda as environment manager, but I doubt this has anything to do with it.
Running tensorboard --logdir=. --host localhost --port 8888 in the console works fine, but it is a bit inconvenient.
Here is the VSCode version:
Version: 1.66.2 (user setup)
Commit: dfd34e8260c270da74b5c2d86d61aee4b6d56977
Date: 2022-04-11T07:46:01.075Z
Electron: 17.2.0
Chromium: 98.0.4758.109
Node.js: 16.13.0
V8: 9.8.177.11-electron.0
OS: Windows_NT x64 10.0.19043
Addendum
I now realize that everything works if I am in a regular Python file. It just doesn't work in a ipynb notebook. This seems like a minor bug - the Python extension should use the notebook's environment if no other Python environment was specified. Or is there a reason not to?

Have you tried to start tensorboard with : %tensorboard --bind_all --logdir ?
As WSL runs on a subnet (bridge), you may need to listen on all IPs .
This solved the problem on my side :-)

Related

Jupyter Notebook Error: "Jupyter command `jupyter-notebook` not found."

I just downloaded vscode using homebrew and install python#3.11 using homebrew as well. I used pip3 install jupyter as I saw other recommend to fix this issue and still no luck. I have downloaded all the extensions on vscode and I have set the kernal to homebrew version of python and I still recieve this issue. Note that I have used notebooks in the past and have never gotten this issue so I am not really sure what it is this time. I have not installed anaconda.
I have tried uninstalling and installing the extensions but no luck. I have tried to pip3 uninstall jupyter, pip3 uninstall notebook and reinstall them and still no luck. I have tried to change the kernal to the default python3 on the mac and still nothing. My mac is m1 running on Ventura 13.2. I am able to run python code on regular python files just not using jupyter notebook. I followed the instructions how to set it up on vscode website but I got this error. Any help would be appreciated thank you.
I have same issue using VSCode on Mac OS.
VSCode's 'Jupyter' plugin is broken, causing VSCode unable to bind with python interpreter. Downgrading from v2023.1.2000312134 to v2022.11.1003412109 fixed my issue.
I had the same issue, running on m1 mac (Ventura 13.2). If you aren't already, make sure you are utilising a python virtual environment:
# Create a python virtual environment
$ python -m venv venv
# Activate your python virtual environment
$ source venv/bin/activate
Form your VSCode Command Palette (Shift+Command+P), search and then choose
Jupyter: Select Interpreter to Start Jupyter Server
You should then select the python version that is associated to your virtual environment (venv).

Why is proxy set in /etc/environment of VSCode devcontainer?

I created a new project and launched an Ubuntu development container.
Without any special settings, the proxy of the started environment was set in /etc/environment as follows.
vscode ➜ /workspaces/etcenv $ cat /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
HTTPS_PROXY="http://proxy.xxx.co.jp:8080"
https_proxy="http://proxy.xxx.co.jp:8080"
NO_PROXY="localhost,127.0.0.1,169.254.169.254,169.254.170.2,xxx.co.jp"
no_proxy="localhost,127.0.0.1,169.254.169.254,169.254.170.2,xxx.co.jp"
HTTP_PROXY="http://proxy.xxx.co.jp:8080"
http_proxy="http://proxy.xxx.co.jp:8080"
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
I've noticed that the addition of capitalized Proxy settings has broken some existing projects.
Earlier versions of VSCode probably didn't do this.
Is this guess correct? Is it possible to disable the setting?
The version I'm using now is:
Version: 1.73.1 (system setup)
Commit: 6261075646f055b99068d3688932416f2346dd3b
Date: 2022-11-09T04:27:29.066Z
Electron: 19.0.17
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Windows_NT x64 10.0.19044
Sandboxed: No
ms-vscode-remote.remote-ssh v0.92.0
An existing project was working in VSCode a couple of months ago.
I don't know if the proxy was set in /etc/environment of the existing project, but I was doing the same operation many times every day with the devcontainer, so I guess the proxy was not set.
I expected the latest version of VSCode to behave the same.
but, Existing projects, which have not changed, are now not working as they used to due to the capitalized proxy set in /etc/environment.

How can I open a New Ubuntu 20.04 shell (WSL2) in VSCode integrated terminal

On my machine I have installed the WSL2 on Windows 10 Pro and a Ubuntu 20.04 LTS distro. I am also using VSCode as editor for programming. I start VSCode in Windows (not in the WSL2 Ubuntu) and there is the possibility to create a new terminal using the profile "New Ubuntu-20.04 (Standard) (WSL)".
Image: Start New Ubuntu 20.04 (Standard) (WSL)
However, this doesn't work as it calls the command "wsl -d Ubuntu-20.04 (Standard)" thus interpreting "(Standard)" as a command to be executed in WSL. This obviously fails as there is no command "(Standard)".
Image: Error message starting the shell
How can I change this profile? Is that possible at all?
As a workaround I can create a new profile in my VSCode user settings and pass the correct argument to the "wsl" command. But then I still have the defective profile entry in the integrated terminal. But I just want to have working entries there.
thanks in advance
Lars
The April 2021 release of VS code fixed the issue.

Can't import plotly in Notebook in Visual Studio Code

I'm trying to create graphs using plotly for the first time. Since I'm currently using Visual Studio Code for my coding (either python scripts or notebooks), I'm currently trying to use plotly in VSC.
I've installed everything from the plotly getting started page (conda installed plotly, notebook, ipywidgets and even jupyter) but I'm still getiing an error when importing.
The thing is, when I've tried importing plotly in a python file in VSC, it's running well. I've also tried running it in a Jupyter Notebook and it's also running.
import plotly.express as px
I'm pretty sure that I've installed everything in the correct environment and I'm using the same environment all throughout.
What do I need to run plotly in a notebook in VSC?
It seems like your python versions/pip versions are different (especially if you're using an env). In Visual studio Code, you can bring up a simple terminal directing to the directory of your project (or env). Just click Terminal > New terminal. This will bring up a terminal (like CMD or terminal) at the bottom of the screen.
From then you can check the version of Pip and python for either your system globally, or the version install in your env. As long as your env is activated, then it will check the versions for the env, not your system.
For macOS:
To show all python installations of your system:
which -a python
To get the version for python 3 (which is what you should be on):
python3 --version
To get the version for pip:
pip -v
For windows:
python3 --version
pip -v
If the versions are incorrect then you can either install the right version of pip in your env or change python paths. First option is recommended.
If you are using macOS. Entering the command which -a python will show a very old Python 2.X version. Do not tamper with this or it's path as it is needed by macOS to run.

How to get my windows conda to recognize my ANTs installed in Ubuntu?

My conda environment that runs python code is on my Windows 10.
I installed ANTs successfully in my Ubuntu- Windows subsystem for Linux.
How do I get my Windows to recognize this now? How do I export the WSL path to my Windows path variable?
This is my WSL Ubuntu in my Windows 10 system, with Ants and N4BiasFieldCorrection
This is my conda environment in Windows 10 unable to find the installed ANTs
Please help.
I don't think you can do what you are asking at the moment. Ubuntu is installed as a separate sub-system in Windows and applications installed in that subsystem are not accessible in Windows. This might change soon but I don't think it's possible right now.
In my opinion, you have to create the conda environment in your WSL, then you can work with it from Windows using Visual Studio Code with Remote - WSL extension.