python - 如何显示我的 Jupyter 笔记本的版本并在 Jupyter 笔记本中运行单元格?我收到错误 : bad interpreter

标签 python kernel anaconda jupyter-notebook

我已经安装了 Anaconda,我使用 conda 环境和 conda 命令来安装软件。

当我输入: jupyter notebook --version

我收到以下错误:

zsh:/Users/cr517/.local/bin/jupyter: 错误的解释器:/Users/cr517/anaconda/envs/snakes/bin/python: 没有这样的文件或目录 5.2.1

我可以通过键入以下命令打开 jupyter notebook:jupyter notebook xyz.ipynb 但我无法运行任何单元格。在我运行它之后,该单元格被标记为 * 。很快,这个消息出现在一个弹出框中:

内核死机,自动重启失败。内核可能无法重新启动。如果您无法重新启动内核,您仍然可以保存笔记本,但在笔记本重新打开之前运行代码将不再有效。

我在打开 jupyter notebok 后在终端中得到了这个:

zsh: /Users/cr517/.local/bin/jupyter: bad interpreter: /Users/cr517/anaconda/envs/snakes/bin/python: no such file or directory
[I 21:01:55.558 NotebookApp] JupyterLab alpha preview extension loaded from /Users/cr517/anaconda/lib/python3.6/site-packages/jupyterlab
[I 21:01:55.558 NotebookApp] JupyterLab application directory is /Users/cr517/anaconda/share/jupyter/lab
[I 21:01:55.564 NotebookApp] Serving notebooks from local directory: /Users/cr517/Documents/teach/demonstrations/python/python-functions-and-modules-master
[I 21:01:55.564 NotebookApp] 0 active kernels
[I 21:01:55.564 NotebookApp] The Jupyter Notebook is running at:
[I 21:01:55.564 NotebookApp] http://localhost:8888/?token=0a0b3368be051aceea02ddfdb677ba5b48724f050e78fa59
[I 21:01:55.564 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 21:01:55.584 NotebookApp] 

    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://localhost:8888/?token=0a0b3368be051aceea02ddfdb677ba5b48724f050e78fa59
[I 21:01:55.852 NotebookApp] Accepting one-time-token-authenticated connection from ::1
[I 21:01:57.808 NotebookApp] Kernel started: 944ec290-db3a-4dc1-97fb-cf440cc384ce
/Users/cr517/anaconda/bin/python: No module named ipykernel_launcher
[I 21:02:00.804 NotebookApp] KernelRestarter: restarting kernel (1/5)
/Users/cr517/anaconda/bin/python: No module named ipykernel_launcher
[I 21:02:03.813 NotebookApp] KernelRestarter: restarting kernel (2/5)
/Users/cr517/anaconda/bin/python: No module named ipykernel_launcher
[I 21:02:06.824 NotebookApp] KernelRestarter: restarting kernel (3/5)
/Users/cr517/anaconda/bin/python: No module named ipykernel_launcher
[W 21:02:07.940 NotebookApp] Timeout waiting for kernel_info reply from 944ec290-db3a-4dc1-97fb-cf440cc384ce
[I 21:02:09.833 NotebookApp] KernelRestarter: restarting kernel (4/5)
kernel 944ec290-db3a-4dc1-97fb-cf440cc384ce restarted
/Users/cr517/anaconda/bin/python: No module named ipykernel_launcher
[W 21:02:12.841 NotebookApp] KernelRestarter: restart failed
[W 21:02:12.842 NotebookApp] Kernel 944ec290-db3a-4dc1-97fb-cf440cc384ce died, removing from map.
kernel 944ec290-db3a-4dc1-97fb-cf440cc384ce restarted failed!
[W 21:02:12.873 NotebookApp] 410 DELETE /api/sessions/eaa457a0-7628-42c4-927f-1428b4ec3b68 (::1): Kernel deleted before session
[W 21:02:12.873 NotebookApp] Kernel deleted before session
[W 21:02:12.873 NotebookApp] 410 DELETE /api/sessions/eaa457a0-7628-42c4-927f-1428b4ec3b68 (::1) 2.10ms referer=http://localhost:8888/notebooks/python_fm_1.ipynb

确实没有 /Users/cr517/anaconda/envs/snakes/bin/python 但为什么 Jupyter Notebook 试图使用它?我这里有一个运行良好的 Python:

which python
/Users/cr517/anaconda/bin/python

?

which -a python
/Users/cr517/anaconda/bin/python
/usr/local/bin/python
/usr/bin/python

which -a jupyter
/Users/cr517/.local/bin/jupyter
/Users/cr517/.local/bin/jupyter
/Users/cr517/.local/bin/jupyter

echo $PATH
/usr/local/opt/hdf5@1.8/bin:/Users/cr517/Documents/phd/project/output/software/DEXTRACTOR:/Users/cr517/Documents/phd/project/output/software/DAZZ_DB:/Users/cr517/Documents/phd/project/output/software/DASCRUBBER:/Users/cr517/Documents/phd/project/output/software/subread-1.5.2-MaxOSX-x86_64/bin:/Users/cr517/Documents/phd/project/output/software/SHRiMP_2_2_2/utils:/Users/cr517/Documents/phd/project/output/software:/Users/cr517/Documents/phd/project/output/software/fastx/bin:/Users/cr517/.local/bin:/Users/cr517/Documents/phd/project/output/software/DAZZ_DB:/Users/cr517/Documents/phd/project/output/software/DASCRUBBER:/Users/cr517/Documents/phd/project/output/software/subread-1.5.2-MaxOSX-x86_64/bin:/Users/cr517/Documents/phd/project/output/software/SHRiMP_2_2_2/utils:/Users/cr517/Documents/phd/project/output/software:/Users/cr517/Documents/phd/project/output/software/fastx/bin:/Users/cr517/.local/bin:/Users/cr517/Documents/phd/project/output/software/DASCRUBBER:/Users/cr517/Documents/phd/project/output/software/subread-1.5.2-MaxOSX-x86_64/bin:/Users/cr517/Documents/phd/project/output/software/SHRiMP_2_2_2/utils:/Users/cr517/Documents/phd/project/output/software:/Users/cr517/Documents/phd/project/output/software/fastx/bin:/Users/cr517/.local/bin:/Users/cr517/Documents/phd/project/output/software/subread-1.5.2-MaxOSX-x86_64/bin:/Users/cr517/Documents/phd/project/output/software/SHRiMP_2_2_2/utils:/Users/cr517/Documents/phd/project/output/software:/Users/cr517/Documents/phd/project/output/software/fastx/bin:/Users/cr517/.local/bin:/Users/cr517/Documents/phd/project/output/software:/Users/cr517/Documents/phd/project/output/software/STAR:/Users/cr517/Documents/phd/project/output/software/fastx/bin:/Users/cr517/.local/bin:/Users/cr517/.local/bin:/Users/cr517/anaconda/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/ncbi/blast/bin:/Library/TeX/texbin:/Users/cr517/Documents/phd/project/multibreak-sv/lib:/Users/cr517/Documents/phd/project/output/software/PBSuite_15.8.24/pbsuite:/Users/cr517/Documents/phd/project/output/software/PBSuite_15.8.24/bin/:/Users/cr517/Documents/phd/project/output/software/blobology
    /Users/cr517/.local/bin/jupyter
    /Users/cr517/.local/bin/jupyter
    /Users/cr517/.local/bin/jupyter
    /Users/cr517/anaconda/bin/jupyter
    /usr/local/bin/jupyter

jupyter kernelspec list
zsh: /Users/cr517/.local/bin/jupyter: bad interpreter: /Users/cr517/anaconda/envs/snakes/bin/python: no such file or directory
Available kernels:
  python3    /Users/cr517/anaconda/lib/python3.6/site-packages/ipykernel/resources
  ir         /Users/cr517/anaconda/share/jupyter/kernels/ir
  python2    /usr/local/share/jupyter/kernels/python2

jupyter notebook 在网络浏览器中打开我的目录,但不创建新笔记本。

我在终端输入 python --version 得到:

Python 3.6.3 :: Anaconda custom (x86_64)

最佳答案

在您的终端上,您可以简单地执行以下操作:

jupyter --version

或者,如果您使用的是笔记本,则执行以下操作:

!jupyter --version

这里是我的输出:

jupyter core     : 4.5.0
jupyter-notebook : 5.2.2
qtconsole        : 4.5.2
ipython          : 5.5.0
ipykernel        : 4.10.1
jupyter client   : 5.3.1
jupyter lab      : not installed
nbconvert        : 5.5.0
ipywidgets       : 7.5.0
nbformat         : 4.4.0
traitlets        : 4.3.2

关于python - 如何显示我的 Jupyter 笔记本的版本并在 Jupyter 笔记本中运行单元格?我收到错误 : bad interpreter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47662692/

相关文章:

python - pip install AttributeError : _DistInfoDistribution__dep_map

python - 如何在一行数据帧中解压列表内的多个字典对象?

python - 代码未附加正确的对象...为什么?

c - 当我编译我的内核时,是什么导致了这个奇怪的警告?传递不兼容的指针类型,期望结构 * 但得到结构 *

linux - 许可和使用 Linux 内核

tensorflow - 将 sudo pip 安装库更改为 anaconda

python - 断点法的使用

python - 溢出错误 : Python int too large to convert to C long

linux - 如何在 Makefile 中查看内核版本

wxpython - 无法在 Anaconda Python 上安装 wxPython