14

I've spent half a day trying to figure it out on my own but now I've run out of ideas and googling requests. So basically what I want is to connect to our Snowflake database using snowflake-connector-python package. I was able to install the package just fine (together with all the related packages that were installed automatically) and my current pip3 list results in this:

Package                    Version
-------------------------- ---------
asn1crypto                 1.3.0
azure-common               1.1.25
azure-core                 1.6.0
azure-storage-blob         12.3.2
boto3                      1.13.26
botocore                   1.16.26
certifi                    2020.6.20
cffi                       1.14.0
chardet                    3.0.4
cryptography               2.9.2
docutils                   0.15.2
gitdb                      4.0.5
GitPython                  3.1.3
idna                       2.9
isodate                    0.6.0
jmespath                   0.10.0
msrest                     0.6.17
oauthlib                   3.1.0
oscrypto                   1.2.0
pip                        20.1.1
pyasn1                     0.2.3
pyasn1-modules             0.0.9
pycparser                  2.20
pycryptodomex              3.9.8
PyJWT                      1.7.1
pyOpenSSL                  19.1.0
python-dateutil            2.8.1
pytz                       2020.1
requests                   2.23.0
requests-oauthlib          1.3.0
s3transfer                 0.3.3
setuptools                 47.3.1
six                        1.15.0
smmap                      3.0.4
snowflake-connector-python 2.2.8
urllib3                    1.25.9
wheel                      0.34.2

Just to be clear, it's a clean python-venv although I've tried it on the main one, too.

When running the following code in VScode:

#!/usr/bin/env python
import snowflake.connector

# Gets the version
ctx = snowflake.connector.connect(
    user='user',
    password='pass',
    account='acc')

I'm getting this error:

AttributeError: module 'snowflake' has no attribute 'connector'

Does anyone have any idea what could be the issue here?

8 Answers 8

16

AttributeError: module 'snowflake' has no attribute 'connector'

Your test code is likely in a file named snowflake.py which is causing a conflict in the import (it is ending up importing itself). Rename the file to some other name and it should allow you to import the right module and run the connector functions.

Sign up to request clarification or add additional context in comments.

1 Comment

I just tried this, and renamed to snowflake_pacakges and still same error - was there another step I needed to do?
11

When I had this issue I had both the snowflake and snowflake-connector-python module installed in my environment, so it was confused on which one to use. If you're trying to use connector, just pip uninstall snowflake

Comments

6

Try importing 'connector' explicitly. I had the same error.

import pandas as pd
import snowflake as sf
from snowflake import connector

2 Comments

Had the same problem and this solved it. Snowflake is an awesome tool with subpar python libraries - even their documentation uses snowflake.connector! :-/
2023 still works!
3

If anyone comes across this same issue and doesn't get reprieve from the above fixes, my install had a snowflake.py file saved to the site-packages folder.

This caused the 'import snowflake.connector' statement to attempt to import from the snowflake.py file instead of the snowflake folder, and of course couldn't find the connector module since the .py file isn't a package. Renaming or moving that file solved my problem.

3 Comments

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.
There were no sources needed. I did the exact same thing and couldn't figure out why it wasn't working. I changed the name of the file to snowflake_connection and it immediately found the package.
This works in 2024!
2

If you have installed both snowflake and snowflake-connector-python, just uninstalling snowflake package will resolve the issue.

_

To list installed python packages, use command

pip list

Comments

0

I installed python 3.6 again. I removed this line from code

#!/usr/bin/env python

It worked.

Comments

0
pip install snowflake-connector-python

Have you tried using this package instead in the jupyter notebook?

Comments

0

I had a sub-folder named snowflake, but depending on how I run the script it either could or could not import the snowflake.connector.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.