Python 导入错误:无法导入名称“ensure_dir_exists”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/48372019/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ImportError: cannot import name 'ensure_dir_exists'
提问by Santosh Kangane
I update the Jupyter notebook from the old version to latest 5.3.1. However, when I try to launch the notebook from anaconda, it throws an import error: I tried to remove and install Jupyter package, still, the issue persists.
我将 Jupyter notebook 从旧版本更新到最新的 5.3.1。但是,当我尝试从 anaconda 启动笔记本时,它会引发导入错误:我尝试删除并安装 Jupyter 包,但问题仍然存在。
Traceback (most recent call last):
File "C:\Users\v-kangsa\AppData\Local\Continuum\anaconda3\Scripts\jupyter-notebook-script.py", line 6, in
from notebook.notebookapp import main
File "C:\Users\v-kangsa\AppData\Local\Continuum\anaconda3\lib\site-packages\notebook\__init__.py", line 25, in
from .nbextensions import install_nbextension
File "C:\Users\v-kangsa\AppData\Local\Continuum\anaconda3\lib\site-packages\notebook\nbextensions.py", line 27, in
from jupyter_core.utils import ensure_dir_exists
ImportError: cannot import name 'ensure_dir_exists'
回答by piratefache
You need to update jupyter_core and jupyter_client manually from your terminal:
您需要从终端手动更新 jupyter_core 和 jupyter_client :
conda update jupyter_core jupyter_client
回答by pavan
If you've installed jupyter using pip3
.
如果您已经使用pip3
.
pip3 install --upgrade jupyter_core jupyter_client
回答by Brayan Cruz
update jupyter core
更新 jupyter 核心
pip install jupyter-core --upgrade
this working for me in Anaconda3 with python 3.6
这在 Anaconda3 中使用 python 3.6 为我工作
回答by Wu Wenter
I've met the same problem when I use ipython notebook.
我在使用ipython notebook时遇到了同样的问题 。
After I tried upgrade jupyter, then I tried reinstall the ipython. The import error seem fixed.
在我尝试升级 jupyter 之后,我尝试重新安装 ipython。导入错误似乎已修复。
pip3 uninstall ipython
pip3 install ipython
pip3 卸载 ipython
pip3 安装 ipython
回答by Pistachio Guoguo
When I tried to install R the notebook was upgraded to 5.3.1 and same problem appeared, however the highest vote answer apparently didn't work for me.
当我尝试安装 R 时,笔记本升级到 5.3.1 并出现了同样的问题,但是最高投票答案显然对我不起作用。
What I did was:
我所做的是:
conda uninstall jupyter notebook
then:
然后:
conda install jupyter notebook
and the problem solved with the old version.
并用旧版本解决了问题。
回答by tbnsilveira
I had a similar issue on Ubuntu after installing RStudio on my system. To solve it, first I tried @MichaelCara suggestion to update jupyter. However, after that I got the following new message error:
在我的系统上安装 RStudio 后,我在 Ubuntu 上遇到了类似的问题。为了解决它,首先我尝试@MichaelCara 建议更新 jupyter。但是,之后我收到以下新消息错误:
ImportError: libsodium.so.23: cannot open shared object file: No such file or directory
导入错误:libsodium.so.23:无法打开共享对象文件:没有那个文件或目录
which I solved installing libsodiumas explained here.
我按照此处的说明解决了安装libsodium 的问题。
In short:
简而言之:
conda update jupyter_core jupyter_client jupyter_console
conda install libsodium
conda 更新 jupyter_core jupyter_client jupyter_console conda
安装 libsodium