Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How configure VSCode to work with pyscript? #23

Open
tms320 opened this issue Sep 12, 2022 · 6 comments
Open

How configure VSCode to work with pyscript? #23

tms320 opened this issue Sep 12, 2022 · 6 comments

Comments

@tms320
Copy link

tms320 commented Sep 12, 2022

I have installed pyscript into Home Assistant (HA). It works properly (I can execute python scripts).
On my client Windows machine I installed HASS Pyscript kernel shim for Jupyter and set settings in pyscript.conf file.
Here is output of jupyter kernelspec list console command:

Available kernels:
python3     C:\Users\trofi\AppData\Roaming\Python\share\jupyter\kernels\python3
pyscript    C:\ProgramData\jupyter\kernels\pyscript

I want to remotely debug my python script /pyscript/test.py located on my HA machine (Ubuntu server).
I installed Jupyter extension in VSCode on my Windows machine and created new Jupyter notebook. What are my next steps to connect it to pyscript?
If I press this:
image
I see this:
image
I don't see pyscript kernel.

@tms320
Copy link
Author

tms320 commented Sep 13, 2022

The output of jupyter notebook command is:
image

The output of jupyter console --kernel=pyscript command is:
image

I can run Jupyter server using python -m notebook command:
image
It opens this web page:
image

But I still don't see pyscript kernel in VSCode...

@tms320
Copy link
Author

tms320 commented Sep 13, 2022

If I create new hass pyscript in web interface:
image
I see the following error(s) in the HA logs:
image

@andrew-from-toronto
Copy link

I had the same issue with vscode not showing the kernel. I based my fix off of this post on a related issue with a different kernel microsoft/vscode-jupyter#8286 (comment)

In short, update the hass pyscript kernelspec to have the full path to where you have python installed. The problem vscode is having is resolving the correct "python" for it to use.

@tms320
Copy link
Author

tms320 commented Oct 9, 2022

I edited 'C:\ProgramData\jupyter\kernels\pyscript\kernel.json' file to specify full path to python interpreter:

{
  "argv": [
    "C:\\Users\\trofi\\AppData\\Local\\Programs\\Python\\Python38\\python.exe",
    "-m",
    "hass_pyscript_kernel",
    "-f",
    "{connection_file}"
  ],
  "display_name": "hass pyscript",
  "language": "python"
}

But it didn't help. I still don't see pyscript kernel in VSCode...
If I try to select interpreter:
image
I see this:
image
What did I miss? Should I start pyscript kernel manually before I run VSCode?

@MaFrom
Copy link

MaFrom commented Nov 7, 2023

I had the same problem, but in the selection there is a possibility to choose 'other kernels' and then it suddenly showed up the hass pyscript kernel for seleciton. Play a little with the import/selection field for the kernel. Unfortunately I cannot reproduce it now.

@NodeJSmith
Copy link

In case it helps anyone else, I installed Jupyter PowerToys (ms-toolsai.vscode-jupyter-powertoys) which adds a pane for selecting kernels, and the pyscript one showed up there without issue.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants