Search code examples
pythonpython-3.xpipsnowflake-cloud-data-platformpython-3.12

Use Snowflake Connector on Python 3.12


I have just switched from Python version 3.11.6 to 3.12.0 Previously it was possible for me to run the following script (I installed snowflake-python-connector):

import snowflake

# Connection to Snowflake
con = snowflake.connector.connect(
    user='your_user',
    password='your_password',
    account='your_account',
    warehouse='your_warehouse',
    role='your_role'
)


But now with the new Python version I receive the error message: "AttributeError: module 'snowflake' has no attribute 'connector'" I could not figure out how to fix it. I know I can just go back to Python version 3.11.6 but is it also possible to use the snowflake connector on the 3.12.0 version?

I have reinstalled the packages snowflake and snowflake-python-connector, that did not help. Also I found the hint to use "import snowflake.connector" instead of "import snowflake" but it did not work for me as well.


Solution

  • Currently, snowflake-connector-python supports Python 3.12

    pip install snowflake-connector-python
    

    If you have both snowflake and snowflake-connector-python installed in your virtual environment you will get

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

    You need to uninstall snowflake

    pip uninstall snowflake
    

    Then:

    import snowflake.connector
    
    # Connection to Snowflake
    con = snowflake.connector.connect(
        user='your_user',
        password='your_password',
        account='your_account',
        warehouse='your_warehouse',
        role='your_role'
    )