如何显示Jupyter笔记本的版本并在Jupyter笔记本中运行单元格?我收到一个错误:翻译错误 [英] How can I display the version of my Jupyter notebook and run cells in Jupyter notebooks? I get an error: bad interpreter

查看:92
本文介绍了如何显示Jupyter笔记本的版本并在Jupyter笔记本中运行单元格?我收到一个错误:翻译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have installed Anaconda and I use the conda environments and the conda command to install software.

当我输入时: jupyter notebook --version

我收到以下错误:

zsh: /Users/cr517/.local/bin/jupyter: bad interpreter: /Users/cr517/anaconda/envs/snakes/bin/python: no such file or directory 5.2.1

zsh: /Users/cr517/.local/bin/jupyter: bad interpreter: /Users/cr517/anaconda/envs/snakes/bin/python: no such file or directory 5.2.1

我可以通过键入以下内容来打开jupyter笔记本:jupyter notebook xyz.ipynb,但是我无法运行任何单元格.运行它后,该单元格会用*标记.很快,此消息出现在弹出框中:

I can open a jupyter notebook by typing: jupyter notebook xyz.ipynb but I cannot run any cells. The cell is marked with * after I run it. Soon, this message appears in a pop-up box:

The kernel has died, and the automatic restart has failed. It is possible the kernel cannot be restarted. If you are not able to restart the kernel, you will still be able to save the notebook, but running code will no longer work until the notebook is reopened.

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

I get this in the terminal after opening a 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:

Indeed there is no /Users/cr517/anaconda/envs/snakes/bin/python but why is Jupyter Notebook trying to use this? I have a well-functioning Python here:

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在网络浏览器中打开我的目录,但没有创建新的笔记本.

jupyter notebook opens my directory in a web browser but does not create a new notebook.

我在终端中键入python --version并得到:

I typed python --version in the terminal and got:

Python 3.6.3 :: Anaconda custom (x86_64)

推荐答案

*如何检查iPython版本

您可以使用conda list ipython

这篇关于如何显示Jupyter笔记本的版本并在Jupyter笔记本中运行单元格?我收到一个错误:翻译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆