Reputation: 173
My qtconsole code is this:
import sys
from qtpy import QtWidgets
from qtconsole.rich_jupyter_widget import RichJupyterWidget
from qtconsole.manager import QtKernelManager
# The ID of an installed kernel, e.g. 'bash' or 'ir'.
USE_KERNEL = 'python3'
def make_jupyter_widget_with_kernel():
"""Start a kernel, connect to it, and create a RichJupyterWidget to use it
"""
kernel_manager = QtKernelManager(kernel_name=USE_KERNEL)
kernel_manager.start_kernel()
kernel_client = kernel_manager.client()
kernel_client.start_channels()
jupyter_widget = RichJupyterWidget()
jupyter_widget.kernel_manager = kernel_manager
jupyter_widget.kernel_client = kernel_client
return jupyter_widget
class MainWindow(QtWidgets.QMainWindow):
"""A window that contains a single Qt console."""
def __init__(self):
super().__init__()
self.jupyter_widget = make_jupyter_widget_with_kernel()
self.setCentralWidget(self.jupyter_widget)
def shutdown_kernel(self):
print('Shutting down kernel...')
self.jupyter_widget.kernel_client.stop_channels()
self.jupyter_widget.kernel_manager.shutdown_kernel()
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
window = MainWindow()
window.show()
app.aboutToQuit.connect(window.shutdown_kernel)
sys.exit(app.exec_())
it successfully compiles when I run it but when I click on the finished pyinstaller (pyinstaller --onefile main.py
or pyinstaller --windowed --onedir Yuro.py
) bundle, this qtconsole errors out with message:
File "main.py", line 38, in <module>
File "main.py", line 28, in __init__
File "main.py", line 14, in make_jupyter_widget_with_kernel
File "jupyter_client/utils.py", line 26, in wrapped
File "jupyter_client/utils.py", line 23, in wrapped
File "nest_asyncio.py", line 70, in run_until_complete
File "asyncio/futures.py", line 201, in result
File "asyncio/tasks.py", line 256, in __step
File "jupyter_client/manager.py", line 362, in _async_start_kernel
File "jupyter_client/manager.py", line 347, in _async_start_kernel
File "jupyter_client/utils.py", line 26, in wrapped
File "jupyter_client/utils.py", line 23, in wrapped
File "nest_asyncio.py", line 70, in run_until_complete
File "asyncio/futures.py", line 201, in result
File "asyncio/tasks.py", line 256, in __step
File "jupyter_client/manager.py", line 308, in _async_pre_start_kernel
File "jupyter_client/manager.py", line 138, in kernel_spec
File "jupyter_client/kernelspec.py", line 294, in get_kernel_spec
File "jupyter_client/kernelspec.py", line 247, in _get_kernel_spec_by_name
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module
File "ipykernel/kernelspec.py", line 16, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module
File "ipykernel/ipkernel.py", line 38, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module
File "ipykernel/debugger.py", line 20, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module
File "debugpy/server/__init__.py", line 9, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module
File "debugpy/_vendored/__init__.py", line 18, in <module>
FileNotFoundError: [Errno 2] No such file or directory: '/var/folders/2n/h8v95wf976v7byjf7s78jfxh0000gn/T/_MEIu7ujzo/debugpy/_vendored'
I took this qtconsole code from the qtconsole github: "https://github.com/jupyter/qtconsole/blob/master/examples/embed_qtconsole.py." Thank you in advance for your help.
Upvotes: 3
Views: 195