问题
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