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

问题描述 投票:2回答:2

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

AttributeError:cffi库'_openssl'没有名为'Cryptography_HAS_ED25519'的函数,常量或全局变量

我已经尝试将最新版本的Cryptography库分别附加到集群,但这给了我同样的问题。我认为它可能与以下链接有关:

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中卸载预安装的加密1.5 python库,以便我可以使用新的目录结构重新安装最新版本的加密(2.5)?

python databricks snowflake-datawarehouse python-cryptography
2个回答
1
投票

过时的图书馆:

%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


0
投票

我找到了问题的答案。

这个问题是由于Databricks中的openssl版本过于过时而导致snowke-sqlalchemy无法使用它。

解决方案如下:

  1. 升级PIP %sh / databricks / python / bin / pip install --upgrade pip
  2. 卸载pyopenssl %sh / databricks / python / bin / pip卸载pyopenssl -y
  3. 安装pyopenssl %sh / databricks / python / bin / pip install --upgrade pyopenssl
  4. 安装snowflake-sqlalchemy %sh / databricks / python / bin / pip install --upgrade snowflake-sqlalchemy

这个问题的答案很有帮助:Python AttributeError: 'module' object has no attribute 'SSL_ST_INIT'

我使用以下代码创建了一个init文件:

dbutils.fs.mkdirs("dbfs:/databricks/init/")

dbutils.fs.put("dbfs:/databricks/init/sf-initiation.sh" ,"""
#!/bin/bash
/databricks/python/bin/pip install --upgrade pip
/databricks/python/bin/pip uninstall pyopenssl -y
/databricks/python/bin/pip install --upgrade pyopenssl
/databricks/python/bin/pip install --upgrade snowflake-sqlalchemy
""", True)

文件中的最后一个命令更新所有过时的包,如:Upgrading all packages with pip

© www.soinside.com 2019 - 2024. All rights reserved.