Skip to main content
 首页 » 编程设计

python之如何在 Python 3 的 Databricks 中使用 python 雪花连接器连接到 Snowflake

2024年12月31日7lori

当我尝试将 snowflake-sqlalchemy 库附加到 Databricks 中的 Python 3 集群时,它破坏了我的 python 构建,并且在我安装后续库时出现以下错误:

AttributeError: cffi library '_openssl' has no function, constant or global variable named 'Cryptography_HAS_ED25519'

我曾尝试将最新版本的密码学库单独附加到集群,但这给了我同样的问题。我认为这可能与以下链接有关:

connecting-to-snowflake-from-azure-databricks-notebook-message-openssl-has-no-function-constant-or-global-variable-named-cryptography

https://github.com/snowflakedb/snowflake-connector-python/issues/32

在第二个链接中它提到了一个解决方法:

The workaround is: 
Uninstall cryptography by running pip uninstall cryptography 
Delete the directory .../site-packages/cryptography/ manually 
Reinstall snowflake-connector-python 
 
Looks like the directory structure of cryptography changed since 1.7.2.* 

有什么方法可以卸载 Databricks 中预安装的 cryptography 1.5 python 库,以便我可以使用新的目录结构重新安装最新版本的 cryptography (2.5)?

请您参考如下方法:

过时的库:

%sh sudo apt-get install python3-pip -y 

其次是:

%sh pip3 install --upgrade snowflake-connector-python 

参见 https://datathirst.net/blog/2019/1/11/databricks-amp-snowflake-python-errors了解更多详情。