问题描述
我在docker上运行的Jupyter Notebook中遇到以下错误.
I'm getting the following error in Jupyter notebook running on docker.
NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:snowflake`
我正在运行以下
from sqlalchemy import create_engine
engine = create_engine(
f'snowflake://asd:asd@bla/analytics/public?warehouse=general&role=analyst'
)
在笔记本中,我可以执行以下命令并使代码工作,结果如下:
From within the Notebook I can execute the following and get the code to work, with results below:
!python3 --version
!echo '---'
!cat test.py
!echo '---'
!python3 test.py
Python 3.6.8 :: Anaconda, Inc.
---
from sqlalchemy import create_engine
engine = create_engine(
f'snowflake://asd:asd@bla/analytics/public?warehouse=general&role=analyst'
)
print(engine)
---
Engine(snowflake://asd:***@bla/analytics/public?role=analyst&warehouse=general)
但是,在Jupyter笔记本中运行相同的create_engine()会返回错误:NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:snowflake
.
However running the same create_engine() from within the Jupyter notebook returns your error: NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:snowflake
.
我真的很困惑为什么会发生这种情况.
I'm really confused as to why this happens.
我什至在我的Dockerfile中添加了pip install --upgrade snowflake-sqlaclchemy
:
I even added the pip install --upgrade snowflake-sqlaclchemy
to my Dockerfile:
# Start from a core stack version https://jupyter-docker-stacks.readthedocs.io/en/latest/using/recipes.html
FROM jupyter/tensorflow-notebook
# Install in the default python3 environment
COPY requirements.txt /tmp/
RUN pip install --requirement /tmp/requirements.txt && \
pip install --upgrade snowflake-sqlalchemy && \
fix-permissions $CONDA_DIR && \
fix-permissions /home/$NB_USER
推荐答案
在笔记本中添加以下内容即可使其正常工作
Adding the following to my notebook got it working
破解方法:
!python3 -m pip install --upgrade snowflake-sqlalchemy
exit()
#once complete, go to Kernel>Restart&Clear Output
更好的解决方案:修改Dockerfile之后,我没有运行docker build --rm -t jupyter/sme-datascience-notebook .
,这已将其修复
Better Solution:I was not running docker build --rm -t jupyter/sme-datascience-notebook .
after modifying my Dockerfile, this fixed it
这篇关于Jupyter Notebook问题-NoSuchModuleError:无法加载插件:sqlalchemy.dialects:snowflake`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!