简体   繁体   English

Jupyter 错误:“没有名为 jupyter_core.paths 的模块”

[英]Jupyter error: "No module named jupyter_core.paths"

Trying to open Jupyter Notebook (OSX 10.11.4) I get the following error:尝试打开 Jupyter Notebook (OSX 10.11.4) 我收到以下错误:

$ jupyter-notebook
Traceback (most recent call last):
  File "/usr/local/bin/jupyter-notebook", line 7, in <module>
    from notebook.notebookapp import main
  File "/Users/geotheory/Library/Python/2.7/lib/python/site-packages/notebook/__init__.py", line 25, in <module>
    from .nbextensions import install_nbextension
  File "/Users/geotheory/Library/Python/2.7/lib/python/site-packages/notebook/nbextensions.py", line 23, in <module>
    from jupyter_core.paths import jupyter_data_dir, jupyter_path, SYSTEM_JUPYTER_PATH
ImportError: No module named jupyter_core.paths

This used to work.这曾经有效。 Any idea how to diagnose?知道如何诊断吗?

I faced the same issue, and was able resolve with the following steps.我遇到了同样的问题,并且能够通过以下步骤解决。

conda create -n py36 python=3.6
conda activate py36
conda install notebook ipykernel jupyterlab

我遇到了同样的问题,只需在 macOS 终端中使用pip install jupyter即可pip install jupyter

If you are using Anaconda, I recommend installing Jupyter to your conda environment using the following:如果您使用的是 Anaconda,我建议您使用以下命令将 Jupyter 安装到您的 conda 环境中:

conda install -c anaconda jupyter

You can then launch Jupyter from the terminal with the following command:然后,您可以使用以下命令从终端启动 Jupyter:

jupyter notebook .

I have encountered similar issue.我遇到过类似的问题。 Basically, I solved it by uninstall python2.7 and re-install newer python & IPython versions.基本上,我通过卸载 python2.7 并重新安装较新的 python 和 IPython 版本来解决它。

Details on how to effectively uninstall python2.7 via Mac OS command line is here: How to uninstall Python 2.7 on a Mac OS X 10.6.4?如何通过 Mac OS 命令行有效卸载 python2.7 的详细信息在这里: 如何在 Mac OS X 10.6.4 上卸载 Python 2.7?

Re-install desired version of IPython via command line.通过命令行重新安装所需版本的 IPython。 In my case, I also needed to re-install Jupyter via:就我而言,我还需要通过以下方式重新安装 Jupyter:

$ pip install jupyter

Good luck.祝你好运。

I met with the similar problem this morning.我今天早上遇到了类似的问题。 As I changed the $PYTHONPATH directory in bash_profile.当我更改 bash_profile 中的 $PYTHONPATH 目录时。 Then I solved by re-specify the python path back to /usr/lib/python2.*.然后我通过将python路径重新指定回/usr/lib/python2.*来解决。 I hope it will help.我希望它会有所帮助。

In my case this was because pip, run with sudo, did not set read and execute rights on the files and directories it created under /usr/local/lib/python2.7/dist-packages .在我的情况下,这是因为使用 sudo 运行的 pip 没有设置它在/usr/local/lib/python2.7/dist-packages下创建的文件和目录的读取和执行权限。

So I used find and chmod to set them, as described there :所以我用查找和chmod来设置他们所描述的

cd /usr/local/lib/python2.7/dist-packages
sudo find ./ -type d -exec chmod a+rx {} \;
sudo find ./ -type f -exec chmod a+r {} \;

In fact, this behaviour of sudo probably arises from the fact that my standard user umask is 0007 (creating private files by default).事实上, sudo这种行为可能是因为我的标准用户 umask 是 0007(默认创建私有文件)。 This seems to transfer to sudo.这似乎转移到sudo。 To avoid this, one can edit the sudo configuration by running sudo visudo and adding the following lines, as per this answer :为避免这种情况,可以通过运行sudo visudo并添加以下行来编辑 sudo 配置,根据此答案

Defaults umask_override
Defaults umask=0022

(although quite late to the party but) You mentioned that 'it used to work' and from your prompt it looks like you're not in your 'virtual environment'. (虽然参加聚会已经很晚了,但是)您提到'it used to work'并且根据您的提示,您似乎不在“虚拟环境”中。 Simply activate your proper virtual environment to have it work like before.只需激活您适当的虚拟环境,让它像以前一样工作。

It happens when you have multiple versions of Python in your system.当您的系统中有多个版本的Python时,就会发生这种情况。 Try to find the correct version by looking in the 'pip' directory:尝试通过查看“pip”目录来找到正确的版本:

which pip

For me, it was located in:对我来说,它位于:

~/bulk/Python/python-3.7.4/bin/

There, you should be able to find the jupyter executable:在那里,您应该能够找到jupyter可执行文件:

$ ls jupyter
jupyter

Try to run it directly by:尝试通过以下方式直接运行它:

./jupyter

Hope this helps.希望这会有所帮助。

只是在我的环境处于活动状态时使用pip install jupyter对我pip install jupyter

I solved this issue in my environment by uninstalling and then reinstalling jupyter notebook.我通过卸载然后重新安装 jupyter notebook 在我的环境中解决了这个问题。 After that, worked like a charm.在那之后,工作就像一个魅力。 While your environment is active, run:在您的环境处于活动状态时,运行:

pip uninstall jupyter notebook

pip install jupyter notebook

Spoiler: not the cleanest solution but just a workaround.剧透:不是最干净的解决方案,只是一种解决方法。

I had the same issue on Linux (Fedora) caused by the launcher in ~/.local/bin/jupyter due to different versions installed globally and from conda.我在 Linux (Fedora) 上遇到了同样的问题,这是由于~/.local/bin/jupyter中的启动器导致的,因为全局安装的版本和 conda 的版本不同。 So I jusst used this workaround (from terminal with conda env) wich worked fine in my case:所以我只是使用了这个解决方法(从带有 conda env 的终端),在我的情况下效果很好:

python3 -m jupyter notebook

从 ubuntu 的 sudo 组中删除用户后,遇到了类似的问题并已修复。

sudo deluser my_user sudo

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM