Jupyter
Install
## Jupyter Lab pip install jupyterlab jupyter-lab jupyter-lab --port=8888 --ip=0.0.0.0
## Jupyter Notebook (Classic) pip install notebook jupyter notebook jupyter notebook --port=8888 --ip=0.0.0.0 #jupyter notebook --port=8888 --ip=0.0.0.0 --allow-root
Troubleshooting - Uncaught Exception in ZMQStream
https://stackoverflow.com/questions/75558109/jupyter-notebook-ubuntu-crash
https://github.com/spyder-ide/spyder/issues/6783
https://qiita.com/hikusema189/items/5c3f988a88850c059fd2
## [E 04:21:41.490 NotebookApp] Uncaught exception in ZMQStream callback ## Traceback (most recent call last): ## File "/opt/conda/lib/python3.8/site-packages/zmq/eventloop/zmqstream.py", line 584, in _run_callback ## f = callback(*args, **kwargs) ## File "/opt/conda/lib/python3.8/site-packages/zmq/eventloop/zmqstream.py", line 308, in stream_callback ## return callback(self, msg) ## File "/opt/conda/lib/python3.8/site-packages/notebook/services/kernels/handlers.py", line 572, in _on_zmq_reply ## super()._on_zmq_reply(stream, msg) ## File "/opt/conda/lib/python3.8/site-packages/notebook/base/zmqhandlers.py", line 256, in _on_zmq_reply ## self.write_message(msg, binary=isinstance(msg, bytes)) ## File "/opt/conda/lib/python3.8/site-packages/tornado/websocket.py", line 334, in write_message ## return self.ws_connection.write_message(message, binary=binary) ## File "/opt/conda/lib/python3.8/site-packages/tornado/websocket.py", line 1081, in write_message ## fut = self._write_frame(True, opcode, message, flags=flags) ## File "/opt/conda/lib/python3.8/site-packages/tornado/websocket.py", line 1056, in _write_frame ## return self.stream.write(frame) ## File "/opt/conda/lib/python3.8/site-packages/tornado/iostream.py", line 539, in write ## self._handle_write() ## File "/opt/conda/lib/python3.8/site-packages/tornado/iostream.py", line 965, in _handle_write ## self._write_buffer.advance(num_bytes) ## File "/opt/conda/lib/python3.8/site-packages/tornado/iostream.py", line 182, in advance ## assert 0 < size <= self._size ## AssertionError
## Upgrade ipykernel pip install --upgrade ipykernel #conda update ipykernel
Magic Command
!pip list !pip install pandas !pip install selenium !apt install chromium-chromedriver !apt install fonts-ipafont !pip freeze > requirements.txt !apt-get update !apt-get install -y python-opengl
Inline Matplotlib
%matplotlib inline
Time Estimation
%%time %%timeit
Venv in Jupyter
https://janakiev.com/blog/jupyter-virtual-envs/
https://qiita.com/Gonsuna/items/80a5d36673ba2b6ef7f0
See Venv for more details on virtual environments
python3 -m venv venv source venv/bin/activate
(venv)$ pip install ipykernel (venv)$ ipython kernel install --user --name=venv
Change the kernel to 'venv' on a web page of Jupyter Notebook
Inline Video
!pip install --upgrade pyvirtualdisplay !apt-get install -y xvfb !apt-get install -y python-opengl !apt-get install -y ffmpeg !apt-get install -y cmake import glob import io import base64 from IPython.display import HTML from IPython import display as ipythondisplay from pyvirtualdisplay import Display display = Display(visible=0, size=(1024, 768)) display.start() show_video() def show_video() : mp4list = glob.glob('output/video/*.mp4') if len(mp4list) > 0 : for mp4 in sorted(mp4list)[0:] : video = io.open(mp4, 'r+b').read() encoded = base64.b64encode(video) ipythondisplay.display(HTML(data='''{mp4}<br> <video alt="{mp4}" autoplay loop controls style="height: 200px;"> <source src="data:output/video/mp4;base64,{src}" type="video/mp4"> </video>'''.format(mp4=mp4, src=encoded.decode('ascii')))) else : print("Could not find any output/video/mp4")
Google Colaboratory
from google.colab import drive drive.mount('/content/drive')
ROOT_PATH = '/content/drive/Shareddrives/Project' %cd $ROOT_PATH
References
Acknowledgments
Daiphys is a professional-service company for research and development of leading-edge technologies in physics and engineering.
Get started accelerating your business through our deep expertise in R&D with AI, quantum computing, and space development; please get in touch with Daiphys today!
Daiphys Technologies LLC - https://www.daiphys.com/