Closed YEM-1 closed 1 year ago
I have the same problem
File "/appenv/lib/python3.10/site-packages/snowflake/connector/__init__.py", line 50, in Connect
return SnowflakeConnection(**kwargs)
File "/appenv/lib/python3.10/site-packages/snowflake/connector/connection.py", line 284, in __init__
self.connect(**kwargs)
File "/appenv/lib/python3.10/site-packages/snowflake/connector/connection.py", line 494, in connect
self.__open_connection()
File "/appenv/lib/python3.10/site-packages/snowflake/connector/connection.py", line 733, in __open_connection
self._authenticate(auth_instance)
File "/appenv/lib/python3.10/site-packages/snowflake/connector/connection.py", line 994, in _authenticate
self.__authenticate(self.__preprocess_auth_instance(auth_instance))
File "/appenv/lib/python3.10/site-packages/snowflake/connector/connection.py", line 1014, in __authenticate
auth.authenticate(
File "/appenv/lib/python3.10/site-packages/snowflake/connector/auth.py", line 257, in authenticate
ret = self._rest._post_request(
File "/appenv/lib/python3.10/site-packages/snowflake/connector/network.py", line 700, in _post_request
ret = self.fetch(
File "/appenv/lib/python3.10/site-packages/snowflake/connector/network.py", line 790, in fetch
ret = self._request_exec_wrapper(
File "/appenv/lib/python3.10/site-packages/snowflake/connector/network.py", line 912, in _request_exec_wrapper
raise e
File "/appenv/lib/python3.10/site-packages/snowflake/connector/network.py", line 833, in _request_exec_wrapper
return_object = self._request_exec(
File "/appenv/lib/python3.10/site-packages/snowflake/connector/network.py", line 1086, in _request_exec
raise err
File "/appenv/lib/python3.10/site-packages/snowflake/connector/network.py", line 988, in _request_exec
raw_ret = session.request(
File "/appenv/lib/python3.10/site-packages/snowflake/connector/vendored/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "/appenv/lib/python3.10/site-packages/snowflake/connector/vendored/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "/appenv/lib/python3.10/site-packages/snowflake/connector/vendored/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/appenv/lib/python3.10/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "/appenv/lib/python3.10/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py", line 382, in _make_request
self._validate_conn(conn)
File "/appenv/lib/python3.10/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py", line 1010, in _validate_conn
conn.connect()
File "/appenv/lib/python3.10/site-packages/snowflake/connector/vendored/urllib3/connection.py", line 411, in connect
self.sock = ssl_wrap_socket(
File "/appenv/lib/python3.10/site-packages/snowflake/connector/ssl_wrap_socket.py", line 81, in ssl_wrap_socket_with_ocsp
from .ocsp_asn1crypto import SnowflakeOCSPAsn1Crypto as SFOCSP
ImportError: cannot import name 'SnowflakeOCSPAsn1Crypto' from partially initialized module 'snowflake.connector.ocsp_asn1crypto' (most likely due to a circular import) (/appenv/lib/python3.10/site-packages/snowflake/connector/ocsp_asn1crypto.py)
Are you importing the module through any special means? How could the module be partially initialized if you are opening a connection already?
I have found running it on another machine solves the issue. The new machine has: • snowflake-connector-python==2.7.6 • Python 3.7.9
As a reminder, the machine with the issue has: • snowflake-connector-python==2.7.4 • Python 3.9.2
Are you importing the module through any special means?
No, not importing through any special means.
How could the module be partially initialized if you are opening a connection already? Not sure. That's why I created the bug!
Any Updates on this? I am facing the same error on python 3.9.2 with snowflake related packages
snowflake-connector-python==2.7.12
snowflake-sqlalchemy==1.3.2
We had a user that was experiencing this error, the machine had the following: Python Vers: 3.9.0 snowflake-connector-python: 2.7.12
The fix was upgrading to Python version 3.9.10 on the same snowflake conn version.
I've experienced this on a lot of machines now. There are many combinations of Python interpreter / snowflake connector version that conflict. That's why it's important to control the versions used with something like pipenv.
I even experienced this with dbt recently. Their own installation guide to install dbt 1.0 installed a conflicting version for me. Then I had to upgrade the snowflake connector after getting this error. Craziness.
FWIW, I've had that happening to me when running dbt on Debian Bullseye, Python 3.9.2, dbt-core==1.3.1, dbt-snowflake==1.3.0 when I ran dbt multithreaded. Single threaded - no problem (apart from things of course taking a long time.)
What happens when you upgrade your snowflake-connector-python in that environment?
On Fri, Dec 9, 2022, 11:59 AM Tomáš Heran @.***> wrote:
FWIW, I've had that happening to me when running dbt on Debian Bullseye, Python 3.9.2, dbt-core==1.3.1, dbt-snowflake==1.3.0 when I ran dbt multithreaded. Single threaded - no problem (apart from things of course taking a long time.)
— Reply to this email directly, view it on GitHub https://github.com/snowflakedb/snowflake-connector-python/issues/1073#issuecomment-1344538549, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJGCUAEGFPLOCSTCODN6GBTWMNQNTANCNFSM5QIIOARQ . You are receiving this because you authored the thread.Message ID: @.***>
What happens when you upgrade your snowflake-connector-python in that environment?
I've upgraded from 2.7.12 to 2.8.3 and no change, still getting this error:
cannot import name 'SnowflakeOCSPAsn1Crypto' from partially initialized module 'snowflake.connector.ocsp_asn1crypto'
(most likely due to a circular import) (/go/src/github.com/Pexeso/analytics/disco_new/pyvenv/lib/python3.9/site-packages/snowflake/connector/ocsp_asn1crypto.py)
FWIW, I've switched to Python 3.9.15 on a different machine and all seems to work just fine even multithreaded.
For completeness, this is the list of the pieces that work for me:
dbt-core==1.3.0
dbt-snowflake==1.3.0
snowflake-connector-python==2.7.12
... the environment where it doesn't work for me differs only in the version of Python - there it's 3.9.2.
FWIW, I believe what this is about is essentially this issue in Python https://bugs.python.org/issue43517. I've verified that the fix (and the fix alone) in 3.9.2 resolves the issues.
It seems like this issue went away for many users by upgrading Python. Please reopen this issue if you are still having this issue after upgrading Python
Please answer these questions before submitting your issue. Thanks!
What version of Python are you using?
Python 3.9.2
What operating system and processor architecture are you using?
Windows-10-10.0.19041-SP0
What are the component versions in the environment (
pip freeze
)?At the end when I list my results, it shows an error:
cannot import name 'SnowflakeOCSPAsn1Crypto' from partially initialized module 'snowflake.connector.ocsp_asn1crypto. (most likely due to a circular import)'
It seems like all the data made it to snowflake, but I would have no way to check if one of the write_pandas() failed. There are no failed
copy
commands in the snowflake query history, so I assume it actually worked.Below is a sample of my code to help you understand what I'm doing. It is not the entire program, but the important part.
The traceback is complaining about the connection, here:
What did you expect to see?
Final threads close? Not sure what is driving this error. I've done this design patter many times.
Can you set logging to DEBUG and collect the logs?
This will reveal too much confidential information to post on the public internet. I'm happy to share logs via support portal, email, etc.