Jupyter Notebook issue - NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:snowflake`

江枫思渺然 提交于 2019-12-25 00:18:01

问题


I'm getting the following error in Jupyter notebook running on docker.

NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:snowflake`

I'm running the following

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)

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.

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 

回答1:


Adding the following to my notebook got it working

Hack Solution:

!python3 -m pip install --upgrade snowflake-sqlalchemy
exit()
#once complete, go to Kernel>Restart&Clear Output

Better Solution: I was not running docker build --rm -t jupyter/sme-datascience-notebook . after modifying my Dockerfile, this fixed it



来源:https://stackoverflow.com/questions/55045712/jupyter-notebook-issue-nosuchmoduleerror-cant-load-plugin-sqlalchemy-dialec

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!