hass-pyscript-jupyter
hass-pyscript-jupyter copied to clipboard
Change kernel default install location
I'm trying to install the kernel inside a venv by running jupyter pyscript install
, as per the instructions in README.md. This is trying to install to /usr/local/share/jupyter
, which I do not want. I see that the install_main
method is capable of installing the kernel to a custom directory, only not upon first install.
Could you add a parser argument to be able to provide a custom directory? Or set a more user/venv based default? Thank you!
I am also having this issue. Would love to keep things in a virtual environment
a good option here would probably be to read an environment variable to allow this to be changed, but really it should default to user dir imo. I have a modified version that successfully installed in my $HOME/.local/share/jupyter/kernels/pyscript
and there are no problems as far as I can tell
If you are running on macOS and hack the install script to work and install, remember to make a link to the install location in ~/Library/Jupyter/kernels/pyscript
to get it listed:
$ jupyter kernelspec list
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
Available kernels:
python3 /opt/homebrew/Cellar/jupyterlab/4.0.0/libexec/lib/python3.11/site-packages/ipykernel/resources
pyscript /Users/msa/Library/Jupyter/kernels/pyscript
I think I'm having the same issue installing in macOS -- running jupyter pyscript install
errors with PermissionError: [Errno 13] Permission denied: '/usr/local/share'
Could someone who got this working share how they hacked the install script? Thank you
Have you tried creating a venv and installing and running it from that?
Yes, whether I install in a conda env or in my base macOS it gives the same error.
I may have a similar/related issue. I am running HA core on ubuntu 22.04. The python version on ubuntu is 3.10 and cannot be upgraded, since apparently, this would break the OS. However, the latest HA versions want python 3.11. Therefore, I had to install 3.11 in /srv/homeassistant, which is then used in the venv that HA is running in. HA is working, and I also got pyscript working.
However, when I activated the venv and executed the instructions to install hass-pyscript-jupyter from within there, it was not working. jupyter kernelspec list
and jupyter pyscript info
give me the correct answers (pyscript kernel shows up). From within the venv, I can fire up jupyter notebook
, however, I only get python3 as a kernel option and not hass-pyscript-jupyter. Also, when I run jupyter console --kernel=pyscript
I get the error messages below, which looks like /usr/bin/python3
is being used when it should really be using /srv/homeassistant/bin/python
. For starters, it says that the pyscript kernelspec cannot be found...
Is this the same bug, or should I open a new one?
[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
P.S.: where would I find the install script? How to hack it?
I don't think my problem was related. I opened a separate issue here: #27 , and I actually found the solution.
@schniepp Install script https://github.com/craigbarratt/hass-pyscript-jupyter/blob/master/hass_pyscript_kernel/install.py