jupyter, jupyter notebook, ipython, virtual-env, kernal, ipykernel --- 这些之间的各种关系是什么

jupyter, jupyter notebook,  python, virtual-env,  kernal  ---  这些之间的各种关系是什么?为什么启动 jupyter notebook 会调用特别复杂?

 

 

 

 

=================================================================

Jupyter(Lab/Server/Notebook) “dynamically” creates a kernel(spec) for your current python environment—that kernel type only exists in that virtual environment. This ensures that you always have a python kernel available to you, and that it matches the environment where your current JupyterLab is running.

When you manually create a kernel spec, using the python -m ipykernel install --user ..., you’re creating a static kernel(spec) on disk that can be discovered from other virtual environments. The advantage of this is that you can install JupyterLab in one virtual environment while running kernels from other virtual environments.

Many people use this feature to keep their kernel environments isolated. They might have different kernels for different tasks/workflows.

=================================================================

Using Virtual Environments in Jupyter as Kernels

When using Jupyter notebooks, you can either use plain text or code. The code blocks we use are kernels. We can create new kernels with ipykernel.

When we create kernels, we can link it to our virtual environment. This becomes very useful when you are creating a new project and you are unsure of the necessary packages you need. Whether you remove two-thirds of the installed packages or install one more, the kernel will always mirror the virtual environment we created.

To do this:

$ python -m ipykernel install --user --name=tutorial

 

 

https://towardsdatascience.com/link-your-virtual-environment-to-jupyter-with-kernels-a69bc61728df

======================================================================

The Jupyter Notebook and other frontends automatically ensure that the IPython kernel is available. However, if you want to use a kernel with a different version of Python, or in a virtualenv or conda environment, you’ll need to install that manually. 

We are using virutalenv, so we need to install IPython kernel in the virtualenv we created in Step 0 above.

======================================================================

 

 

/home/software/anaconda3/bin/jupyter notebook --allow-root --notebook-dir='/data/pigenhancer/' --ip 0.0.0.0
[E 16:18:30.835 NotebookApp] [nb_conda_kernels] error loading /home/niuie/software/Anaconda/share/jupyter/kernels/python3/kernel.json:
    Invalid control character at: line 3 column 38 (char 50)
[I 16:18:30.838 NotebookApp] [nb_conda_kernels] enabled, 4 kernels found
[W 16:18:31.113 NotebookApp] Error loading server extension jupyter_nbextensions_configurator
    Traceback (most recent call last):
      File "/home/software/anaconda3/lib/python3.8/site-packages/notebook/notebookapp.py", line 2026, in init_server_extensions
        mod = importlib.import_module(modulename)
      File "/home/software/anaconda3/lib/python3.8/importlib/__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
      File "<frozen importlib._bootstrap>", line 991, in _find_and_load
      File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
    ModuleNotFoundError: No module named 'jupyter_nbextensions_configurator'
[I 16:18:31.185 NotebookApp] JupyterLab extension loaded from /home/software/anaconda3/lib/python3.8/site-packages/jupyterlab
[I 16:18:31.185 NotebookApp] JupyterLab application directory is /home/software/anaconda3/share/jupyter/lab
[I 16:18:31.377 NotebookApp] [nb_conda] enabled
[I 16:18:31.378 NotebookApp] Serving notebooks from local directory: /data/pigenhancer
[I 16:18:31.378 NotebookApp] Jupyter Notebook 6.5.2 is running at:
[I 16:18:31.378 NotebookApp] http://ibiomed:8888/
[I 16:18:31.378 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 16:18:46.827 NotebookApp] 404 GET /nbextensions/nbextensions_configurator/config_menu/main.js?v=20230129161830 (36.44.226.68) 11.080000ms referer=http://202.200.112.247:8888/notebooks/other/%E6%9C%AA%E5%91%BD%E5%90%8D.ipynb
[W 16:18:46.848 NotebookApp] 404 GET /nbextensions/execute_time/Exec.js?v=20230129161830 (36.44.226.68) 1.630000ms referer=http://202.200.112.247:8888/notebooks/other/%E6%9C%AA%E5%91%BD%E5%90%8D.ipynb
[I 16:18:46.915 NotebookApp] Kernel started: a12bf546-aacd-4f24-af8b-12961585293f, name: mydlenv
[W 16:18:46.929 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20230129161830 (36.44.226.68) 1.930000ms referer=http://202.200.112.247:8888/notebooks/other/%E6%9C%AA%E5%91%BD%E5%90%8D.ipynb
[W 16:19:00.186 NotebookApp] 404 GET /nbextensions/nbextensions_configurator/tree_tab/main.js?v=20230129161830 (36.44.226.68) 1.980000ms referer=http://202.200.112.247:8888/tree/other
[E 16:20:42.719 NotebookApp] [nb_conda_kernels] error loading /home/niujunjie/software/Anaconda/share/jupyter/kernels/python3/kernel.json:
    Invalid control character at: line 3 column 38 (char 50)
[W 16:20:42.752 NotebookApp] Notebook other/decode/files/preprocessing_DNase_2overlap.ipynb is not trusted
[W 16:20:42.771 NotebookApp] 404 GET /nbextensions/nbextensions_configurator/config_menu/main.js?v=20230129161830 (36.44.226.68) 1.900000ms referer=http://202.200.112.247:8888/notebooks/other/decode/files/preprocessing_DNase_2overlap.ipynb
[W 16:20:42.792 NotebookApp] 404 GET /nbextensions/execute_time/Exec.js?v=20230129161830 (36.44.226.68) 1.950000ms referer=http://202.200.112.247:8888/notebooks/other/decode/files/preprocessing_DNase_2overlap.ipynb
[W 16:20:42.803 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20230129161830 (36.44.226.68) 2.090000ms referer=http://202.200.112.247:8888/notebooks/other/decode/files/preprocessing_DNase_2overlap.ipynb
[I 16:20:43.051 NotebookApp] Kernel started: 93987891-ba9f-4674-a69e-0aa8943e96bd, name: mydlenv
[I 16:20:46.902 NotebookApp] Saving file at /other/未命名.ipynb
[I 16:20:48.901 NotebookApp] Starting buffering for 93987891-ba9f-4674-a69e-0aa8943e96bd:b89add7694de4ff3a9aa9d00ff85bcab
[W 16:20:55.502 NotebookApp] Notebook other/decode/files/preprocessing_DNase_2overlap.ipynb is not trusted
[W 16:20:55.525 NotebookApp] 404 GET /nbextensions/nbextensions_configurator/config_menu/main.js?v=20230129161830 (36.44.226.68) 2.200000ms referer=http://202.200.112.247:8888/notebooks/other/decode/files/preprocessing_DNase_2overlap.ipynb
[W 16:20:55.549 NotebookApp] 404 GET /nbextensions/execute_time/Exec.js?v=20230129161830 (36.44.226.68) 1.790000ms referer=http://202.200.112.247:8888/notebooks/other/decode/files/preprocessing_DNase_2overlap.ipynb
[W 16:20:55.553 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20230129161830 (36.44.226.68) 1.390000ms referer=http://202.200.112.247:8888/notebooks/other/decode/files/preprocessing_DNase_2overlap.ipynb
[I 16:22:02.039 NotebookApp] Saving file at /other/decode/files/preprocessing_DNase_2overlap.ipynb
[W 16:22:02.040 NotebookApp] Notebook other/decode/files/preprocessing_DNase_2overlap.ipynb is not trusted
[I 16:22:55.858 NotebookApp] Saving file at /other/decode/files/preprocessing_DNase_2overlap.ipynb
[W 16:22:55.859 NotebookApp] Notebook other/decode/files/preprocessing_DNase_2overlap.ipynb is not trusted
[I 16:23:41.987 NotebookApp] Saving file at /other/decode/files/preprocessing_DNase_2overlap.ipynb
[W 16:23:41.988 NotebookApp] Notebook other/decode/files/preprocessing_DNase_2overlap.ipynb is not trusted

posted @ 2023-10-10 19:57  emanlee  阅读(96)  评论(0编辑  收藏  举报