Giter Club home page Giter Club logo

hass-pyscript-jupyter's People

Contributors

acambitsis avatar basnijholt avatar craigbarratt avatar flexible avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

hass-pyscript-jupyter's Issues

kernel crashes when non-unicode is used

For example, the kernel crashes when doing

x = "โš ๏ธ๐Ÿ”‹โ˜ ๏ธ"

I see this error in the Home Assistant log:

shell_listen exception Traceback (most recent call last): File "/config/custom_components/pyscript/jupyter_kernel.py", line 254, in decode return json.loads(msg.decode('ascii')) UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 783: ordinal not in range(128)

Instructions not Working for python3.11 in a venv

I am running python3.11 in a venv (on ubuntu 22.04), and in this particular case, the instructions to get hass-pyscript-jupyter to run are not working.

For context, I am running HA core (v2023.08) on Ubuntu 22.04. The most recent HA versions require python3.11, whereas Ubuntu requires 3.10. Thus, I installed python3.11 in venv that HA is running in anyway. Using the instructions, I tried to install hass-pyscript-jupyter inside the same venv, and I ran into the problems described below.

The installation of hass_pyscript_kernel' looked OK, and jupyter kernelspec listandjupyter pyscript infogave me the correct answers (pyscript kernel shows up). From within the venv, I can fire upjupyter notebook, however, I only get python3 as a kernel option and not hass-pyscript-jupyter. Also, when I run jupyter console --kernel=pyscriptI get the error messages below, which looks like/usr/bin/python3is being used when it should really be using/srv/homeassistant/bin/python`. For starters, it says that the pyscript kernelspec cannot be found...

[ZMQTerminalIPythonApp] WARNING | Kernelspec name pyscript cannot be found!                                                                                          
[ZMQTerminalIPythonApp] ERROR | No such kernel named pyscript                                                                                                        
Traceback (most recent call last):                                                                                                                                   
  File "/usr/lib/python3/dist-packages/jupyter_client/manager.py", line 71, in wrapper out = await method(self, *args, **kwargs)                                                                                                                        
  File "/usr/lib/python3/dist-packages/jupyter_client/manager.py", line 376, in _async_start_kernel kernel_cmd, kw = await ensure_async(self.pre_start_kernel(**kw))                                                                                                 
  File "/usr/lib/python3/dist-packages/jupyter_client/utils.py", line 26, in wrapped raise e                                                                                                                                                          
  File "/usr/lib/python3/dist-packages/jupyter_client/utils.py", line 23, in wrapped return loop.run_until_complete(future)                                                                                                                           
  File "/usr/lib/python3/dist-packages/nest_asyncio.py", line 81, in run_until_complete return f.result()                                                                                                                                                
  File "/usr/lib/python3.10/asyncio/futures.py", line 201, in result raise self._exception.with_traceback(self._exception_tb)                                                                                                         
  File "/usr/lib/python3.10/asyncio/tasks.py", line 232, in __step result = coro.send(None)                                                                                                                                         
  File "/usr/lib/python3/dist-packages/jupyter_client/manager.py", line 339, in _async_pre_start_kernel self.kernel_spec,                                                                                                                                                
  File "/usr/lib/python3/dist-packages/jupyter_client/manager.py", line 169, in kernel_spec self._kernel_spec = self.kernel_spec_manager.get_kernel_spec(self.kernel_name)                                                                                   
  File "/usr/lib/python3/dist-packages/jupyter_client/kernelspec.py", line 292, in get_kernel_spec raise NoSuchKernel(kernel_name) jupyter_client.kernelspec.NoSuchKernel: No such kernel named pyscript                                                                                                
Traceback (most recent call last):                                                                                                                                   
  File "/usr/bin/jupyter-console", line 33, in <module> sys.exit(load_entry_point('jupyter-console==6.4.0', 'console_scripts', 'jupyter-console')())                                                                     
  File "/usr/lib/python3/dist-packages/jupyter_core/application.py", line 264, in launch_instance return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)                                                                                               
  File "/usr/lib/python3/dist-packages/traitlets/config/application.py", line 845, in launch_instance app.initialize(argv)                                                                                                                                             
  File "/usr/lib/python3/dist-packages/traitlets/config/application.py", line 88, in inner return method(app, *args, **kwargs)                                                                                                                              
  File "/usr/lib/python3/dist-packages/jupyter_console/app.py", line 136, in initialize self.init_shell()                                                                                                                                                
  File "/usr/lib/python3/dist-packages/jupyter_console/app.py", line 103, in init_shell JupyterConsoleApp.initialize(self)                                            
  File "/usr/lib/python3/dist-packages/jupyter_client/consoleapp.py", line 365, in initialize self.init_kernel_manager()                                                    
  File "/usr/lib/python3/dist-packages/jupyter_client/consoleapp.py", line 319, in init_kernel_manager self.kernel_manager.start_kernel(**kwargs)                                    
  File "/usr/lib/python3/dist-packages/jupyter_client/utils.py", line 26, in wrapped raise e                                                                                                                                                          
  File "/usr/lib/python3/dist-packages/jupyter_client/utils.py", line 23, in wrapped return loop.run_until_complete(future)                                        
  File "/usr/lib/python3/dist-packages/nest_asyncio.py", line 81, in run_until_complete return f.result()                                                                                                                                                
  File "/usr/lib/python3.10/asyncio/futures.py", line 201, in result raise self._exception.with_traceback(self._exception_tb)                      
  File "/usr/lib/python3.10/asyncio/tasks.py", line 232, in __step result = coro.send(None)                                                      
  File "/usr/lib/python3/dist-packages/jupyter_client/manager.py", line 79, in wrapper raise e                                                                                                                                                          
  File "/usr/lib/python3/dist-packages/jupyter_client/manager.py", line 71, in wrapper out = await method(self, *args, **kwargs)                                                                                                                        
  File "/usr/lib/python3/dist-packages/jupyter_client/manager.py", line 376, in _async_start_kernel kernel_cmd, kw = await ensure_async(self.pre_start_kernel(**kw))                                                                                                 
  File "/usr/lib/python3/dist-packages/jupyter_client/utils.py", line 26, in wrapped raise e                                                                                                                                                          
  File "/usr/lib/python3/dist-packages/jupyter_client/utils.py", line 23, in wrapped return loop.run_until_complete(future)                                                                                                                           
  File "/usr/lib/python3/dist-packages/nest_asyncio.py", line 81, in run_until_complete return f.result()                                                                                                                                                
  File "/usr/lib/python3.10/asyncio/futures.py", line 201, in result raise self._exception.with_traceback(self._exception_tb)                                                                                                         
  File "/usr/lib/python3.10/asyncio/tasks.py", line 232, in __step result = coro.send(None)                                                                                                                                         
  File "/usr/lib/python3/dist-packages/jupyter_client/manager.py", line 339, in _async_pre_start_kernel self.kernel_spec,                                                                                                                                                
  File "/usr/lib/python3/dist-packages/jupyter_client/manager.py", line 169, in kernel_spec self._kernel_spec = self.kernel_spec_manager.get_kernel_spec(self.kernel_name)                                                                                   
  File "/usr/lib/python3/dist-packages/jupyter_client/kernelspec.py", line 292, in get_kernel_spec

issues running pyscript kernel - new random ports

i tried to install the jupiter notebook but it keeps getting the same errors.
when i look in Hass the service exist and the log (debug enabled) is empty

I 2023-07-27 23:24:49.167 ServerApp] Kernel started: 65aa09b1-7f4c-4065-ab3e-d24566cd34e8
hass_pyscript_kernel: got jupyter client config={'shell_port': 62433, 'iopub_port': 62434, 'stdin_port': 62435, 'control_port': 62437, 'hb_port': 62436, 'ip': '127.0.0.1', 'key': 'c2acfa21-0f69694e2940a724c2888d88', 'transport': 'tcp', 'signature_scheme': 'hmac-sha256', 'kernel_name': 'pyscript', 'jupyter_session': 'c:\\jupyter\\pyscriptTutorial.ipynb'}
hass_pyscript_kernel: about to do service call post homeassistant.local:8123/api/services/pyscript/jupyter_kernel_start
hass_pyscript_kernel: got error homeassistant.local:8123/api/services/pyscript/jupyter_kernel_start (url=homeassistant.local:8123/api/services/pyscript/jupyter_kernel_start)
[I 2023-07-27 23:24:52.159 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (1/5), new random ports
hass_pyscript_kernel: got jupyter client config={'shell_port': 62433, 'iopub_port': 62434, 'stdin_port': 62435, 'control_port': 62437, 'hb_port': 62436, 'ip': '127.0.0.1', 'key': 'c2acfa21-0f69694e2940a724c2888d88', 'transport': 'tcp', 'signature_scheme': 'hmac-sha256', 'kernel_name': 'pyscript', 'jupyter_session': 'c:\\jupyter\\pyscriptTutorial.ipynb'}
hass_pyscript_kernel: about to do service call post homeassistant.local:8123/api/services/pyscript/jupyter_kernel_start
hass_pyscript_kernel: got error homeassistant.local:8123/api/services/pyscript/jupyter_kernel_start (url=homeassistant.local:8123/api/services/pyscript/jupyter_kernel_start)

Connection refused error?

I have HASS running on a hypriot based RPi3. I am running jupyter under miniconda for python 3 on my windows 10 box.

I additionally use mobaxterm to jump into the embedded devices on my wifi from the windows 10 box, so have no problems connecting to the HASS device. I can readily browse to the HASS device and access the device using http://black-pearl.local:8123/ or using the raw IP etc.

I used HACS to install pyscript onto the RPi3, went through the usual drill. Installed integration from HACS, added the integration under configuration tab, then rebooted etc.

I installed hass-pyscript-jupyter as per instructions. I updated the file pyscript.conf with HASS device IP (tried both raw IP and black-pearl.local). I included a long lived token in hass_token etc.

Getting WinError 1225 The computer refused the network connection.

At a loss why, if I can get to the same address from the browser on my pc, that the jupyter kernel for pyscript cannot connect.

Have tried recreating hass_token on the off chance of a block copy error. Still the same outcome. Connection refused.

Jupyter fails with request failed with 401: Unauthorized

Hi. I'm trying to create a new notebook. I've added my host/token to the config file. Do you know what is wrong?

[I 15:35:11.394 NotebookApp] Creating new notebook in
[I 15:35:12.249 NotebookApp] Kernel started: 99a9e5f8-ae80-430d-9b69-54f27e22280e, name: pyscript
hass_pyscript_kernel: request failed with 401: Unauthorized (url=http://homeassistant.local:8123/api/services/pyscript/jupyter_kernel_start)
[I 15:35:15.241 NotebookApp] KernelRestarter: restarting kernel (1/5), new random ports
hass_pyscript_kernel: request failed with 401: Unauthorized (url=http://homeassistant.local:8123/api/services/pyscript/jupyter_kernel_start)
[I 15:35:18.257 NotebookApp] KernelRestarter: restarting kernel (2/5), new random ports
hass_pyscript_kernel: request failed with 401: Unauthorized (url=http://homeassistant.local:8123/api/services/pyscript/jupyter_kernel_start)
[I 15:35:21.273 NotebookApp] KernelRestarter: restarting kernel (3/5), new random ports
hass_pyscript_kernel: request failed with 401: Unauthorized (url=http://homeassistant.local:8123/api/services/pyscript/jupyter_kernel_start)
[I 15:35:24.288 NotebookApp] KernelRestarter: restarting kernel (4/5), new random ports
hass_pyscript_kernel: request failed with 401: Unauthorized (url=http://homeassistant.local:8123/api/services/pyscript/jupyter_kernel_start)
[I 15:35:27.304 NotebookApp] KernelRestarter: restarting kernel (5/5), new random ports
hass_pyscript_kernel: request failed with 401: Unauthorized (url=http://homeassistant.local:8123/api/services/pyscript/jupyter_kernel_start)
[W 15:35:30.319 NotebookApp] KernelRestarter: restart failed

Jupyter can't see pyscript/scripts/ context, but can see pyscript/modules/ ones

My pyscript/scripts context has gone missing in Jupyter, making it very hard to debug code. Un-installing and re-installing the shim has had no effect.

In Jupyter, my list of available global contexts is correct, except for the missing script context:
['jupyter_1', 'modules.dic_tools', 'modules.logit', 'modules.physics', 'modules.reports']

If I try to switch to the missing context the way I used to, I now get a NameError:
Exception in <jupyter_1> line 1: pyscript.set_global_ctx('scripts.mkwd_main') ^ NameError: global context 'scripts.mkwd_main' does not exist

I'm not sure exactly what initiated the problem, although I suspect it started when I first added modules.

Any suggestions? Thanks in advance!

Only log.error gets prints in jupyter notebook tutorial. log.debug produces no output.

Trying out pyscript with the jupyter notebook tutorial and none of the log.debug messages print anything. I'm connected successfully and can read states but only log.errors prints results in the notebook and log.warn is not defined. I've never used jupyter before and have little python experience so I'm sorry if I've missed something obvious.

https support

Is there an easy way to make it work with https?

Without having to set up a reverse proxy...

Ignored when using jupyter kernelspec remove x

(jupyter) (base) C:\Users\pierc\dev\jupyter>jupyter kernelspec list
Available kernels:
  dyalog-kernel    C:\Users\pierc\AppData\Roaming\jupyter\kernels\dyalog-kernel
  pyscript         c:\users\pierc\dev\jupyter\share\jupyter\kernels\pyscript
  python3          c:\users\pierc\dev\jupyter\share\jupyter\kernels\python3

(jupyter) (base) C:\Users\pierc\dev\jupyter>jupyter kernelspec remove pyscript
Kernel specs to remove:
Remove 0 kernel specs [y/N]: y

(jupyter) (base) C:\Users\pierc\dev\jupyter>jupyter kernelspec list
Available kernels:
  dyalog-kernel    C:\Users\pierc\AppData\Roaming\jupyter\kernels\dyalog-kernel
  pyscript         c:\users\pierc\dev\jupyter\share\jupyter\kernels\pyscript
  python3          c:\users\pierc\dev\jupyter\share\jupyter\kernels\python3

Note the remove command reports 0, zero, nadda, for removal?

SyntaxError kills kernel

Not sure if this is unexpected, but a SyntaxError results in a dying kernel and kernel restart:

image
image

Pyscript autocomplete doesn't work in VSCode

I have installed Pyscript integration to Home Assistant (it runs on Ubuntu machine).
Then I installed HASS Pyscript kernel shim for Jupyter on my Windows machine (where VSCode installed).
If I open the browser-based Jupyter client (using 'jupyter notebook' command) and create new notebook, the autocomplete of HASS objects works fine (using Tab key). For example:
image
image
But in VSCode autocomplete for HASS objects doesn't work (I press Ctrl+Space key combination):
image
image
What am I doing wrong?

Code completion from ipykernel?

Is there a way to get the code completion features with the pyscript kernel that you get when you run the ipykernel? For instance the ipykernel gives you detailed documentation and completion for something like math.floor() using (shift + tab). When using the pyscript kernel I'm not able to access that.

print doesn't work

When writing scripts in a Jupyter notebook it is often useful to print something. Unfortunately, print doesn't work.

Is this intended?

Documentation Request: vscode jupyter integration

Like many programmers and Home Assistant users, VSCode is my editor of choice. VSCode has Jupyter Notebook functionality builtin. It even supports multiple kernels. However, I get errors when attempting to use it "locally".

Unsupported KernelSpec file. args must be [<pythonPath>, '-m', <moduleName>, arg1, arg2, ..]. Provied /usr/bin/python3 --ip=127.0.0.1 --stdin=9003 --control=9001 --hb=9000 --Session.signature_scheme="hmac-sha256" --Session.key=b"89b5054b-983d-4ac9-b2ee-d8fe74606e74" --shell=9002 --transport="tcp" --iopub=9004 --f=/tmp/tmp-3332Qc6ejHA53Qtk.json

If I, however, run jupyter notebook on the command line and then paste the URL it provides in to VSCode as the remote server, it works fine.

Do you use VSCode when working through Jupyter, or are you using the browser-based application? Do you have any tips to make this work?

Unable to connect

When starting a notebook:

(py38) basnijholt-imac  โžœ  Downloads  jupyter-notebook Untitled.ipynb --debug
[D 18:44:38.116 NotebookApp] Searching ['/Users/basnijholt/Downloads', '/Users/basnijholt/.jupyter', '/Users/basnijholt/miniconda3/envs/py38/etc/jupyter', '/usr/local/etc/jupyter', '/etc/jupyter'] for config files
[D 18:44:38.117 NotebookApp] Looking for jupyter_config in /etc/jupyter
[D 18:44:38.117 NotebookApp] Looking for jupyter_config in /usr/local/etc/jupyter
[D 18:44:38.117 NotebookApp] Looking for jupyter_config in /Users/basnijholt/miniconda3/envs/py38/etc/jupyter
[D 18:44:38.117 NotebookApp] Looking for jupyter_config in /Users/basnijholt/.jupyter
[D 18:44:38.117 NotebookApp] Looking for jupyter_config in /Users/basnijholt/Downloads
[D 18:44:38.118 NotebookApp] Looking for jupyter_notebook_config in /etc/jupyter
[D 18:44:38.118 NotebookApp] Looking for jupyter_notebook_config in /usr/local/etc/jupyter
[D 18:44:38.118 NotebookApp] Looking for jupyter_notebook_config in /Users/basnijholt/miniconda3/envs/py38/etc/jupyter
[D 18:44:38.118 NotebookApp] Looking for jupyter_notebook_config in /Users/basnijholt/.jupyter
[D 18:44:38.119 NotebookApp] Loaded config file: /Users/basnijholt/.jupyter/jupyter_notebook_config.json
[D 18:44:38.119 NotebookApp] Looking for jupyter_notebook_config in /Users/basnijholt/Downloads
[D 18:44:38.120 NotebookApp] Raising open file limit: soft 256->4096; hard 9223372036854775807->9223372036854775807
[D 18:44:38.123 NotebookApp] Paths used for configuration of jupyter_notebook_config:
    	/etc/jupyter/jupyter_notebook_config.json
[D 18:44:38.124 NotebookApp] Paths used for configuration of jupyter_notebook_config:
    	/usr/local/etc/jupyter/jupyter_notebook_config.json
[D 18:44:38.124 NotebookApp] Paths used for configuration of jupyter_notebook_config:
    	/Users/basnijholt/miniconda3/envs/py38/etc/jupyter/jupyter_notebook_config.d/ipyparallel-serverextension.json
    	/Users/basnijholt/miniconda3/envs/py38/etc/jupyter/jupyter_notebook_config.json
[D 18:44:38.125 NotebookApp] Paths used for configuration of jupyter_notebook_config:
    	/Users/basnijholt/.jupyter/jupyter_notebook_config.json
[I 18:44:38.382 NotebookApp] Loading IPython parallel extension
[D 18:44:38.401 NotebookApp] [jupyter_nbextensions_configurator] Loading 0.4.1
[D 18:44:38.402 NotebookApp] [jupyter_nbextensions_configurator]   Editing templates path to add /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/jupyter_nbextensions_configurator/templates
[D 18:44:38.402 NotebookApp] [jupyter_nbextensions_configurator]   Editing nbextensions path to add /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/jupyter_nbextensions_configurator/static
[D 18:44:38.402 NotebookApp] [jupyter_nbextensions_configurator]   Adding new handlers
[I 18:44:38.402 NotebookApp] [jupyter_nbextensions_configurator] enabled 0.4.1
[I 18:44:38.402 NotebookApp] Serving notebooks from local directory: /Users/basnijholt/Downloads
[I 18:44:38.402 NotebookApp] Jupyter Notebook 6.1.3 is running at:
[I 18:44:38.402 NotebookApp] http://localhost:8888/?token=fd8b9eb8f8fb0bea2d10e5e4809f8e88d9381677ca8a7a18
[I 18:44:38.402 NotebookApp]  or http://127.0.0.1:8888/?token=fd8b9eb8f8fb0bea2d10e5e4809f8e88d9381677ca8a7a18
[I 18:44:38.402 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 18:44:38.489 NotebookApp]

    To access the notebook, open this file in a browser:
        file:///Users/basnijholt/Library/Jupyter/runtime/nbserver-20823-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=fd8b9eb8f8fb0bea2d10e5e4809f8e88d9381677ca8a7a18
     or http://127.0.0.1:8888/?token=fd8b9eb8f8fb0bea2d10e5e4809f8e88d9381677ca8a7a18
[D 18:44:39.764 NotebookApp] Accepting token-authenticated connection from ::1
[D 18:44:39.767 NotebookApp] Using contents: services/contents
[D 18:44:39.847 NotebookApp] Path base/images/favicon-notebook.ico served from /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/notebook/static/base/images/favicon-notebook.ico
[D 18:44:39.847 NotebookApp] Path components/jquery-ui/themes/smoothness/jquery-ui.min.css served from /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/notebook/static/components/jquery-ui/themes/smoothness/jquery-ui.min.css
[D 18:44:39.849 NotebookApp] Path components/jquery-typeahead/dist/jquery.typeahead.min.css served from /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/notebook/static/components/jquery-typeahead/dist/jquery.typeahead.min.css
[D 18:44:39.849 NotebookApp] Path components/bootstrap-tour/build/css/bootstrap-tour.min.css served from /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/notebook/static/components/bootstrap-tour/build/css/bootstrap-tour.min.css
[D 18:44:39.851 NotebookApp] Path components/codemirror/lib/codemirror.css served from /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/notebook/static/components/codemirror/lib/codemirror.css
[D 18:44:39.852 NotebookApp] Path style/style.min.css served from /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/notebook/static/style/style.min.css
[D 18:44:39.853 NotebookApp] Path notebook/css/override.css served from /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/notebook/static/notebook/css/override.css
[D 18:44:39.853 NotebookApp] Path components/es6-promise/promise.min.js served from /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/notebook/static/components/es6-promise/promise.min.js
[D 18:44:39.854 NotebookApp] Path components/react/react.production.min.js served from /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/notebook/static/components/react/react.production.min.js
[D 18:44:39.854 NotebookApp] Path components/react/react-dom.production.min.js served from /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/notebook/static/components/react/react-dom.production.min.js
[D 18:44:39.854 NotebookApp] Path components/create-react-class/index.js served from /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/notebook/static/components/create-react-class/index.js
[D 18:44:39.855 NotebookApp] Path components/requirejs/require.js served from /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/notebook/static/components/requirejs/require.js
[D 18:44:39.855 NotebookApp] Path base/images/logo.png served from /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/notebook/static/base/images/logo.png
[D 18:44:40.012 NotebookApp] Paths used for configuration of notebook:
    	/etc/jupyter/nbconfig/notebook.json
[D 18:44:40.012 NotebookApp] Paths used for configuration of notebook:
    	/usr/local/etc/jupyter/nbconfig/notebook.json
[D 18:44:40.013 NotebookApp] Paths used for configuration of notebook:
    	/Users/basnijholt/miniconda3/envs/py38/etc/jupyter/nbconfig/notebook.d/widgetsnbextension.json
    	/Users/basnijholt/miniconda3/envs/py38/etc/jupyter/nbconfig/notebook.json
[D 18:44:40.013 NotebookApp] Paths used for configuration of notebook:
    	/Users/basnijholt/.jupyter/nbconfig/notebook.json
[D 18:44:40.274 NotebookApp] Path components/text-encoding/lib/encoding.js served from /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/notebook/static/components/text-encoding/lib/encoding.js
[D 18:44:40.274 NotebookApp] Path notebook/js/main.min.js served from /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/notebook/static/notebook/js/main.min.js
[D 18:44:40.286 NotebookApp] 200 GET /notebooks/Untitled.ipynb?token=fd8b9eb8f8fb0bea2d10e5e4809f8e88d9381677ca8a7a18 (::1) 521.67ms
[D 18:44:40.292 NotebookApp] Initializing websocket connection /api/kernels/b17056c9-11a4-41a2-be78-2a415de096d8/channels
[W 18:44:40.337 NotebookApp] 404 GET /api/kernels/b17056c9-11a4-41a2-be78-2a415de096d8/channels?session_id=d78d3fd55a224a2380c44523ffbda5f9 (::1): Kernel does not exist: b17056c9-11a4-41a2-be78-2a415de096d8
[D 18:44:40.338 NotebookApp] Using contents: services/contents
[D 18:44:40.369 NotebookApp] Path base/images/favicon.ico served from /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/notebook/static/base/images/favicon.ico
[W 18:44:40.378 NotebookApp] 404 GET /api/kernels/b17056c9-11a4-41a2-be78-2a415de096d8/channels?session_id=d78d3fd55a224a2380c44523ffbda5f9 (::1) 86.62ms referer=None
[D 18:44:40.380 NotebookApp] Path components/MathJax/MathJax.js served from /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/notebook/static/components/MathJax/MathJax.js
[D 18:44:40.381 NotebookApp] 304 GET /static/components/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML-full,Safe&delayStartupUntil=configured (::1) 1.77ms
[D 18:44:40.404 NotebookApp] Path custom.css served from /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/notebook/static/custom/custom.css
[D 18:44:40.405 NotebookApp] 304 GET /custom/custom.css (::1) 1.69ms
[D 18:44:40.475 NotebookApp] Path components/MathJax/config/TeX-AMS-MML_HTMLorMML-full.js served from /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/notebook/static/components/MathJax/config/TeX-AMS-MML_HTMLorMML-full.js
[D 18:44:40.476 NotebookApp] 304 GET /static/components/MathJax/config/TeX-AMS-MML_HTMLorMML-full.js?V=2.7.8 (::1) 1.02ms
[D 18:44:40.587 NotebookApp] Path services/contents.js served from /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/notebook/static/services/contents.js
[D 18:44:40.589 NotebookApp] 200 GET /static/services/contents.js?v=20200828184438 (::1) 3.10ms
[D 18:44:40.659 NotebookApp] Path components/MathJax/config/Safe.js served from /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/notebook/static/components/MathJax/config/Safe.js
[D 18:44:40.660 NotebookApp] 304 GET /static/components/MathJax/config/Safe.js?V=2.7.8 (::1) 0.97ms
[D 18:44:40.674 NotebookApp] Paths used for configuration of notebook:
    	/etc/jupyter/nbconfig/notebook.json
[D 18:44:40.674 NotebookApp] Paths used for configuration of notebook:
    	/usr/local/etc/jupyter/nbconfig/notebook.json
[D 18:44:40.675 NotebookApp] Paths used for configuration of notebook:
    	/Users/basnijholt/miniconda3/envs/py38/etc/jupyter/nbconfig/notebook.d/widgetsnbextension.json
    	/Users/basnijholt/miniconda3/envs/py38/etc/jupyter/nbconfig/notebook.json
[D 18:44:40.676 NotebookApp] Paths used for configuration of notebook:
    	/Users/basnijholt/.jupyter/nbconfig/notebook.json
[D 18:44:40.676 NotebookApp] 200 GET /api/config/notebook?_=1598633080534 (::1) 3.93ms
[D 18:44:40.677 NotebookApp] Paths used for configuration of common:
    	/etc/jupyter/nbconfig/common.json
[D 18:44:40.678 NotebookApp] Paths used for configuration of common:
    	/usr/local/etc/jupyter/nbconfig/common.json
[D 18:44:40.678 NotebookApp] Paths used for configuration of common:
    	/Users/basnijholt/miniconda3/envs/py38/etc/jupyter/nbconfig/common.json
[D 18:44:40.679 NotebookApp] Paths used for configuration of common:
    	/Users/basnijholt/.jupyter/nbconfig/common.json
[D 18:44:40.679 NotebookApp] 200 GET /api/config/common?_=1598633080535 (::1) 6.39ms
[D 18:44:40.720 NotebookApp] Found kernel python3 in /Users/basnijholt/miniconda3/envs/py38/share/jupyter/kernels
[D 18:44:40.720 NotebookApp] Found kernel pyscript in /Users/basnijholt/miniconda3/envs/py38/share/jupyter/kernels
[D 18:44:40.724 NotebookApp] 304 GET /api/kernelspecs (::1) 4.53ms
[D 18:44:40.822 NotebookApp] 200 GET /api/contents/Untitled.ipynb?type=notebook&_=1598633080536 (::1) 10.29ms
[D 18:44:40.824 NotebookApp] Path custom.js served from /Users/basnijholt/.jupyter/custom/custom.js
[D 18:44:40.824 NotebookApp] 200 GET /custom/custom.js?v=20200828184438 (::1) 1.19ms
[D 18:44:41.023 NotebookApp] 200 GET /api/contents/Untitled.ipynb/checkpoints?_=1598633080537 (::1) 2.00ms
[D 18:44:41.301 NotebookApp] Path jupyter-js-widgets/extension.js served from /Users/basnijholt/miniconda3/envs/py38/share/jupyter/nbextensions/jupyter-js-widgets/extension.js
[D 18:44:41.303 NotebookApp] Path jupyter-black-master/jupyter-black.js served from /Users/basnijholt/Library/Jupyter/nbextensions/jupyter-black-master/jupyter-black.js
[D 18:44:41.304 NotebookApp] 200 GET /nbextensions/jupyter-black-master/jupyter-black.js?v=20200828184438 (::1) 1.29ms
[D 18:44:41.308 NotebookApp] Path nbextensions_configurator/config_menu/main.js served from /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/jupyter_nbextensions_configurator/static/nbextensions_configurator/config_menu/main.js
[D 18:44:41.309 NotebookApp] 200 GET /nbextensions/nbextensions_configurator/config_menu/main.js?v=20200828184438 (::1) 2.07ms
[D 18:44:41.309 NotebookApp] Path contrib_nbextensions_help_item/main.js served from /Users/basnijholt/Library/Jupyter/nbextensions/contrib_nbextensions_help_item/main.js
[D 18:44:41.310 NotebookApp] 200 GET /nbextensions/contrib_nbextensions_help_item/main.js?v=20200828184438 (::1) 2.57ms
[D 18:44:41.311 NotebookApp] Path code_prettify/isort.js served from /Users/basnijholt/Library/Jupyter/nbextensions/code_prettify/isort.js
[D 18:44:41.312 NotebookApp] 200 GET /nbextensions/code_prettify/isort.js?v=20200828184438 (::1) 1.71ms
[D 18:44:41.313 NotebookApp] 200 GET /nbextensions/jupyter-js-widgets/extension.js?v=20200828184438 (::1) 13.26ms
[D 18:44:41.333 NotebookApp] Path components/MathJax/extensions/TeX/newcommand.js served from /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/notebook/static/components/MathJax/extensions/TeX/newcommand.js
[D 18:44:41.333 NotebookApp] 304 GET /static/components/MathJax/extensions/TeX/newcommand.js?V=2.7.8 (::1) 1.05ms
[D 18:44:41.335 NotebookApp] Path components/MathJax/extensions/TeX/begingroup.js served from /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/notebook/static/components/MathJax/extensions/TeX/begingroup.js
[D 18:44:41.335 NotebookApp] 304 GET /static/components/MathJax/extensions/TeX/begingroup.js?V=2.7.8 (::1) 1.35ms
[D 18:44:41.336 NotebookApp] Path components/MathJax/extensions/MathML/content-mathml.js served from /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/notebook/static/components/MathJax/extensions/MathML/content-mathml.js
[D 18:44:41.336 NotebookApp] 304 GET /static/components/MathJax/extensions/MathML/content-mathml.js?V=2.7.8 (::1) 1.53ms
[D 18:44:41.388 NotebookApp] Starting kernel: ['/Users/basnijholt/miniconda3/envs/py38/bin/python', '/Users/basnijholt/miniconda3/envs/py38/share/jupyter/kernels/pyscript/hass_pyscript_kernel.py', '/Users/basnijholt/Library/Jupyter/runtime/kernel-7b5f6d54-ac0c-4211-bf97-8b34583e7005.json']
[D 18:44:41.396 NotebookApp] Connecting to: tcp://127.0.0.1:50087
[D 18:44:41.397 NotebookApp] Connecting to: tcp://127.0.0.1:50085
[I 18:44:41.399 NotebookApp] Kernel started: 7b5f6d54-ac0c-4211-bf97-8b34583e7005, name: pyscript
[D 18:44:41.399 NotebookApp] Kernel args: {'kernel_name': 'pyscript', 'cwd': '/Users/basnijholt/Downloads'}
[D 18:44:41.400 NotebookApp] 201 POST /api/sessions (::1) 57.15ms
[D 18:44:41.402 NotebookApp] Path components/MathJax/jax/output/HTML-CSS/fonts/STIX-Web/fontdata.js served from /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/notebook/static/components/MathJax/jax/output/HTML-CSS/fonts/STIX-Web/fontdata.js
[D 18:44:41.402 NotebookApp] 304 GET /static/components/MathJax/jax/output/HTML-CSS/fonts/STIX-Web/fontdata.js?V=2.7.8 (::1) 1.35ms
[D 18:44:41.440 NotebookApp] Path components/MathJax/extensions/Safe.js served from /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/notebook/static/components/MathJax/extensions/Safe.js
[D 18:44:41.441 NotebookApp] 304 GET /static/components/MathJax/extensions/Safe.js?V=2.7.8 (::1) 2.52ms
[D 18:44:41.484 NotebookApp] Initializing websocket connection /api/kernels/7b5f6d54-ac0c-4211-bf97-8b34583e7005/channels
[D 18:44:41.486 NotebookApp] Requesting kernel info from 7b5f6d54-ac0c-4211-bf97-8b34583e7005
[D 18:44:41.486 NotebookApp] Connecting to: tcp://127.0.0.1:50084
[D 18:44:41.522 NotebookApp] Path jupyter-black-master/kernel_exec_on_cell.js served from /Users/basnijholt/Library/Jupyter/nbextensions/jupyter-black-master/kernel_exec_on_cell.js
[D 18:44:41.523 NotebookApp] 200 GET /nbextensions/jupyter-black-master/kernel_exec_on_cell.js?v=20200828184438 (::1) 2.33ms
[D 18:44:41.529 NotebookApp] Path code_prettify/kernel_exec_on_cell.js served from /Users/basnijholt/Library/Jupyter/nbextensions/code_prettify/kernel_exec_on_cell.js
[D 18:44:41.530 NotebookApp] 200 GET /nbextensions/code_prettify/kernel_exec_on_cell.js?v=20200828184438 (::1) 1.70ms
[D 18:44:41.536 NotebookApp] Path components/codemirror/keymap/sublime.js served from /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/notebook/static/components/codemirror/keymap/sublime.js
[D 18:44:41.537 NotebookApp] 200 GET /static/components/codemirror/keymap/sublime.js?v=20200828184438 (::1) 1.16ms
yo
[D 18:44:41.712 NotebookApp] Path components/codemirror/addon/search/searchcursor.js served from /Users/basnijholt/miniconda3/envs/py38/lib/python3.8/site-packages/notebook/static/components/codemirror/addon/search/searchcursor.js
[D 18:44:41.713 NotebookApp] 200 GET /static/components/codemirror/addon/search/searchcursor.js?v=20200828184438 (::1) 1.85ms
[D 18:44:45.216 NotebookApp] Initializing websocket connection /api/kernels/b17056c9-11a4-41a2-be78-2a415de096d8/channels
[W 18:44:45.217 NotebookApp] Replacing stale connection: b17056c9-11a4-41a2-be78-2a415de096d8:d78d3fd55a224a2380c44523ffbda5f9

I added here

while True:
try:
iopub_server = await asyncio.start_server(
null_server, ip_host, config["iopub_port"]
)
iopub_server.close()
break
except OSError:
await asyncio.sleep(0.25)

            while True:
                try:
                    kernel_reader, kernel_writer = await asyncio.open_connection(
                        self.ip_host, self.kernel_port
                    )
                    break
                except Exception as e:  # pylint: disable=broad-except
                    print(e)  # <-------------------------------------------- this
                    await asyncio.sleep(0.25)

and then I get many of these exceptions printed (10s every second) when I start the notebook:

[Errno 61] Connect call failed ('127.0.0.1', 56459)
[Errno 61] Connect call failed ('127.0.0.1', 56461)
[Errno 61] Connect call failed ('127.0.0.1', 56460)
[Errno 61] Connect call failed ('127.0.0.1', 56459)
[Errno 61] Connect call failed ('127.0.0.1', 56460)
[Errno 61] Connect call failed ('127.0.0.1', 56461)
[Errno 61] Connect call failed ('127.0.0.1', 56459)

How configure VSCode to work with pyscript?

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.

Issues running the kernel

After installing on my Mac, I cant get the hass-pyscript-jupyter to work
Running 'jupyter kernelspec list':

[ListKernelSpecs] WARNING | Native kernel (python3) is not available
[ListKernelSpecs] WARNING | Native kernel (python3) is not available
Available kernels:
  pyscript    /usr/local/share/jupyter/kernels/pyscript

Running 'jupyter pyscript info':

hass_pyscript_kernel version 1.0.0 installed
Kernel pyscript installed in /usr/local/share/jupyter/kernels/pyscript
Config settings from /usr/local/share/jupyter/kernels/pyscript/pyscript.conf:
    hass_host = 192.168.1.63
    hass_url = http://192.168.1.63:8123
    hass_token = 6MTYxNzE5MDI1OSwiZXhwIjoxOTMyNTUwyoPnHd8vvF0upJAKRCzsek
    hass_proxy = None

If I run 'juptyer notebook', all seems ok:

[I 2021-03-31 13:42:38.768 LabApp] JupyterLab extension loaded from /usr/local/Cellar/jupyterlab/3.0.12/libexec/lib/python3.9/site-packages/jupyterlab
[I 2021-03-31 13:42:38.769 LabApp] JupyterLab application directory is /usr/local/Cellar/jupyterlab/3.0.12/libexec/share/jupyter/lab
[I 13:42:38.776 NotebookApp] Serving notebooks from local directory: /Users/denver
[I 13:42:38.777 NotebookApp] Jupyter Notebook 6.2.0 is running at:
[I 13:42:38.777 NotebookApp] http://localhost:8888/?token=8c639d693d8f0
[I 13:42:38.777 NotebookApp]  or http://127.0.0.1:8888/?token=8c639d693d8f0
[I 13:42:38.777 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 13:42:38.781 NotebookApp] 
    
    To access the notebook, open this file in a browser:
        file:///Users/denver/Library/Jupyter/runtime/nbserver-4284-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=8c639d693d8f0
     or http://127.0.0.1:8888/?token=8c639d693d8f0

If I then select 'hass pyscript' in Jupyter notebooks 'New' menu I get:

[I 18:46:35.274 NotebookApp] Creating new notebook in 
[I 18:46:36.394 NotebookApp] Kernel started: 5f607b3a-3390-4b7c-bc5b-939c3f47782d, name: pyscript
[W 18:46:36.442 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20210331184622 (::1) 28.070000ms referer=http://localhost:8888/notebooks/Untitled4.ipynb?kernel_name=pyscript
/usr/local/Cellar/jupyterlab/3.0.12/libexec/bin/python3.9: No module named hass_pyscript_kernel
[I 18:46:39.380 NotebookApp] KernelRestarter: restarting kernel (1/5), new random ports
/usr/local/Cellar/jupyterlab/3.0.12/libexec/bin/python3.9: No module named hass_pyscript_kernel
[I 18:46:42.389 NotebookApp] KernelRestarter: restarting kernel (2/5), new random ports
/usr/local/Cellar/jupyterlab/3.0.12/libexec/bin/python3.9: No module named hass_pyscript_kernel
[I 18:46:45.400 NotebookApp] KernelRestarter: restarting kernel (3/5), new random ports
/usr/local/Cellar/jupyterlab/3.0.12/libexec/bin/python3.9: No module named hass_pyscript_kernel
[I 18:46:48.413 NotebookApp] KernelRestarter: restarting kernel (4/5), new random ports
/usr/local/Cellar/jupyterlab/3.0.12/libexec/bin/python3.9: No module named hass_pyscript_kernel
[W 18:46:51.422 NotebookApp] KernelRestarter: restart failed
[W 18:46:51.423 NotebookApp] Kernel 5f607b3a-3390-4b7c-bc5b-939c3f47782d died, removing from map.
[W 18:47:36.469 NotebookApp] Timeout waiting for kernel_info reply from 5f607b3a-3390-4b7c-bc5b-939c3f47782d
[E 18:47:36.472 NotebookApp] Error opening stream: HTTP 404: Not Found (Kernel does not exist: 5f607b3a-3390-4b7c-bc5b-939c3f47782d)

Any ideas where to go from here or what to try please.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.