12

I am working on a notebook on a SageMaker instance at my work. My goal is to connect my jupyter notebook to the snowflake database so as to query some data. Here are some details regarding my problem;

(practiceenv) sh-4.2$ python --version
Python 3.8.6

In the same environment, I did run the command;

conda list

And I could see the package;

# Name                    Version                   Build      Channel
 snowflake-connector-python 2.3.10                    py38h51da96c_0    conda-forge

So it seems the correct package is there. Next, I did create a jupyter notebook(condapython3 kernel) in the same environment and tried to import the package

import snowflake.connector
ModuleNotFoundError: No module named 'snowflake

I was able to get the dependencies installed. Please see the screenshot.enter image description here May I get some help on how to debug this error?

1
  • It looks like you installed the packages in (practiceenv) environment. Does your notebook run in (practiceenv)? Or is it in (python3)? The documentation gives you instruction how to install the packages in desired environment. aws.amazon.com/premiumsupport/knowledge-center/… Commented Apr 29, 2021 at 19:45

4 Answers 4

14
pip install snowflake-connector-python

Have you tried it in jupyter-notebook?

3
  • Appreciate your help. May I know, how is this different from installing using pip command in the terminal. Feedback is appreciated.
    – jay
    Commented Feb 17, 2021 at 0:41
  • As per my understanding. Installing packages via jupyter-notebook scope is local or they can be used(imported) only within jupyter-notebook. But if you install pip packages via terminal they become globally installed packages. Having said that in order to use the globally installed packages the PATH needs to be set properly. This might be the reason it is showing no module found error. Commented Feb 17, 2021 at 7:41
  • I was able to rectify the error after using this command in my CMD.
    – JustCoder
    Commented May 18, 2022 at 20:09
11

Uninstall snowflake first (pip uninstall snowflake)

Then install snowflake again(pip install snowflake-connector-python==2.8.3)

This should resolve the issue.

2
  • Just came to this solution, and it worked for the same error I was facing as the OP. It appears that having Snowflake installed prior to the snowflake-connector-python causes issues in the init.py file.
    – swolfe2
    Commented Jul 11, 2023 at 20:35
  • For me, the issue started when installing snowflake-snowpark-python. I uninstalled it, then installed snowflake and then installed snowflake-snowpark-python and that worked. But your comment helped a ton, thanks!
    – deesolie
    Commented Apr 5 at 16:19
4

You can make use of pip install snowflake.sqlalchemy with this you can get well with the connector you are looking for.

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Aug 21, 2022 at 16:30
0

I ran into the same error while sourcing a Python script from the R terminal (using the reticulate package). The R terminal was launched from the base conda environment. First I tried pip install snowflake-connector-python in the base environment and also in the native Python environment (conda deactivated), but it didn't work. I managed to fix the problem by opening the R terminal in the base environment and installing the Snowflake connector with reticulate:

reticulate::py_install("snowflake-connector-python")

Not the answer you're looking for? Browse other questions tagged or ask your own question.