Dev Space

Customize & extend the power of Alteryx. SDKs, APIs, custom tools, and more!

General Discussions has some can't miss conversations going on right now! From conversations about automation to sharing your favorite Alteryx memes, there's something for everyone. Make it part of your community routine!

SOLVED

Issue creating Virtual Environment with Snowflake Connector (openSSL error)

bobpeers
8 - Asteroid

I'm building a Snowflake connector using the Python SDK but have hit an issue when creating the virtual environment (this is in Alteryx 2020.4.5.12471)

 

Firstly if I use the standard Python tool, run as an administrator and run

 

pip install snowflake-connector-python

 

This installs without any problems and using the import works perfectly. So in Alteryx's own Python tool everything works fine.

 

import snowflake.connector

 

Next I create my custom tool using a virtual environment.(Snowflake_venv). Everything packages fine and installs correctly and without errors but when I use the tool in Alteryx I get this stack trace.

 

Error: Snowflake Output (1): Traceback (most recent call last):
  File "SnowflakeEngine.py", line 15, in <module>
  File "C:\Users\bob\AppData\Roaming\Alteryx\Engine/../Tools\Snowflake_venv\Lib\site-packages\snowflake\connector\__init__.py", line 17, in <module>
    from .connection import SnowflakeConnection
  File "C:\Users\bob\AppData\Roaming\Alteryx\Engine/../Tools\Snowflake_venv\Lib\site-packages\snowflake\connector\connection.py", line 22, in <module>
    from .auth import Auth
  File "C:\Users\bob\AppData\Roaming\Alteryx\Engine/../Tools\Snowflake_venv\Lib\site-packages\snowflake\connector\auth.py", line 19, in <module>
    from .auth_keypair import AuthByKeyPair
  File "C:\Users\bob\AppData\Roaming\Alteryx\Engine/../Tools\Snowflake_venv\Lib\site-packages\snowflake\connector\auth_keypair.py", line 20, in <module>
    from .network import KEY_PAIR_AUTHENTICATOR
  File "C:\Users\bob\AppData\Roaming\Alteryx\Engine/../Tools\Snowflake_venv\Lib\site-packages\snowflake\connector\network.py", line 19, in <module>
    import OpenSSL.SSL
  File "C:\Users\bob\AppData\Roaming\Alteryx\Engine/../Tools\Snowflake_venv\Lib\site-packages\OpenSSL\__init__.py", line 8, in <module>
    from OpenSSL import crypto, SSL
  File "C:\Users\bob\AppData\Roaming\Alteryx\Engine/../Tools\Snowflake_venv\Lib\site-packages\OpenSSL\crypto.py", line 15, in <module>
    from OpenSSL._util import (
  File "C:\Users\bob\AppData\Roaming\Alteryx\Engine/../Tools\Snowflake_venv\Lib\site-packages\OpenSSL\_util.py", line 6, in <module>
    from cryptography.hazmat.bindings.openssl.binding import Binding
  File "C:\Users\bob\AppData\Roaming\Alteryx\Engine/../Tools\Snowflake_venv\Lib\site-packages\cryptography\hazmat\bindings\openssl\binding.py", line 14, in <module>
    from cryptography.hazmat.bindings._openssl import ffi, lib
ImportError: DLL load failed while importing _openssl: The specified module could not be found.

 

I checked the packages installed in the Snowflake_venv I created and they are exactly the same as the ones in the JupyterTool_venv so it doesn't seem to be caused by different package versions.

asn1crypto==1.4.0
azure-common==1.1.26
azure-core==1.9.0
azure-storage-blob==12.6.0
boto3==1.16.33
botocore==1.19.33
certifi==2020.12.5
cffi==1.14.4
chardet==3.0.4
cryptography==3.3
idna==2.10
isodate==0.6.0
jmespath==0.10.0
msrest==0.6.19
oauthlib==3.1.0
oscrypto==1.2.1
pycparser==2.20
pycryptodomex==3.9.9
PyJWT==1.7.1
pyOpenSSL==19.1.0
python-dateutil==2.8.1
pytz==2020.4
requests==2.23.0
requests-oauthlib==1.3.0
s3transfer==0.3.3
six==1.15.0
snowflake-connector-python==2.3.7
urllib3==1.25.11

 

Right now my best guess is that some DLL files used by OpenSSL are not being referenced correctly in the venv but I'm not sure why this works in the Python tool but not in the SDK.

 

Any help would be appreciated 😎

tlarsen7572
11 - Bolide

Hi Bob,

 

When I created a virtual environment it does so with an old version of pip (version 18).  When I try to install snowflake-connector-python, I get an error building the openssl package.  After I upgrade to the latest version of pip (version 20), installation of snowflake-connector-python works just fine and I can import it in my code without a problem.

 

Can you try running the following command in your virtual environment and then re-install the Snowflake connector?

 

python -m pip install --upgrade pip

 

Note: I think this issue only happens when you manually create a virtual environment.  If you package your tool as a YXI, Alteryx will upgrade pip as part of the installation process, so your users should not run into this error.

 

Tom 

bobpeers
8 - Asteroid

Hi Tom,

 

thanks for the input but unfortunately it doesn't fix my issue ☹️

 

I'm creating a virtual environment and then packaging into a YXI using the requirements.txt file before installing. The package installs fine with no errors and I confirm the version of pip it installs is 20.1.1.

 

The environment looks fine but I still get this error.

 

/Bob

bobpeers
8 - Asteroid

OK, so I managed to fix my own problem 😂 Details are here is anyone else hits this issue. 

 

Basically when you create a virtual environment using the SDK tool it automatically uses the latest versions of all the libraries and it turn out these are not compatible with each other. After checking the Snowflake site I found a requirements file that has been tested against Python 3.8 that Alteryx now uses.

 

The file can be found here, https://github.com/snowflakedb/snowflake-connector-python/blob/master/tested_requirements/requiremen...

 

The supported versions of the packages are:

 

asn1crypto==1.4.0
azure-common==1.1.25
azure-core==1.8.2
azure-storage-blob==12.5.0
boto3==1.15.18
botocore==1.18.18
certifi==2020.6.20
cffi==1.14.3
chardet==3.0.4
cryptography==2.9.2
idna==2.10
isodate==0.6.0
jmespath==0.10.0
msrest==0.6.19
oauthlib==3.1.0
oscrypto==1.2.1
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
six==1.15.0
snowflake-connector-python==2.3.7
urllib3==1.25.11