ModuleNotFound for SQLAlchemy and Snowflake Database

That would be because I didn’t provide any packages with the template, try running:

poetry add package-name

For each package your project needs. (Replacing package-name with the package to install.)

got it. should you always use poetry add package name instead of pip install?

looks like the snowflake package had been auto-installed, which likely conflicted with this package. Run in Shell:

sed -i '/ignoredPackages/s/\]/, "snowflake"]/' .replit;poetry remove snowflake

If this isn’t the case, (since it seems your repl is private) please create a minimal repl which reproduces the issue, and send the link (just the URL in the address bar)

that’s recommended because it’s better at dependency management and is what replit uses by default, although if you ever encounter an error with Poetry, the way to fix it is often pip install -U poetry

1 Like

We’re getting somewhere now I’m getting this error. I believe it’s because I’m trying an outbound connection to the snowflake database? Just a shot in the dark. Are there things that need to be done and setup to connect to external databases?

Traceback (most recent call last):
  File "main.py", line 132, in <module>
    with engine.connect() as con:
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 3325, in connect
    return self._connection_cls(self, close_with_result=close_with_result)
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 96, in __init__
    else engine.raw_connection()
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 3404, in raw_connection
    return self._wrap_pool_connect(self.pool.connect, _connection)
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 3371, in _wrap_pool_connect
    return fn()
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 327, in connect
    return _ConnectionFairy._checkout(self)
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 894, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 493, in checkout
    rec = pool._do_get()
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/sqlalchemy/pool/impl.py", line 146, in _do_get
    self._dec_overflow()
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/sqlalchemy/pool/impl.py", line 143, in _do_get
    return self._create_connection()
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 273, in _create_connection
    return _ConnectionRecord(self)
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 388, in __init__
    self.__connect()
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 691, in __connect
    pool.logger.debug("Error on connect(): %s", e)
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 686, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/sqlalchemy/engine/create.py", line 574, in connect
    return dialect.connect(*cargs, **cparams)
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/snowflake/sqlalchemy/snowdialect.py", line 854, in connect
    super().connect(
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 598, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/snowflake/connector/__init__.py", line 51, in Connect
    return SnowflakeConnection(**kwargs)
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/snowflake/connector/connection.py", line 292, in __init__
    self.connect(**kwargs)
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/snowflake/connector/connection.py", line 542, in connect
    self.__open_connection()
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/snowflake/connector/connection.py", line 781, in __open_connection
    self._authenticate(auth_instance)
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/snowflake/connector/connection.py", line 1044, in _authenticate
    self.__authenticate(self.__preprocess_auth_instance(auth_instance))
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/snowflake/connector/connection.py", line 1064, in __authenticate
    auth.authenticate(
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/snowflake/connector/auth.py", line 257, in authenticate
    ret = self._rest._post_request(
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/snowflake/connector/network.py", line 704, in _post_request
    ret = self.fetch(
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/snowflake/connector/network.py", line 794, in fetch
    ret = self._request_exec_wrapper(
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/snowflake/connector/network.py", line 917, in _request_exec_wrapper
    raise e
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/snowflake/connector/network.py", line 837, in _request_exec_wrapper
    return_object = self._request_exec(
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/snowflake/connector/network.py", line 1116, in _request_exec
    raise err
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/snowflake/connector/network.py", line 1018, in _request_exec
    raw_ret = session.request(
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/snowflake/connector/vendored/requests/sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/snowflake/connector/vendored/requests/sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/snowflake/connector/vendored/requests/adapters.py", line 489, in send
    resp = conn.urlopen(
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py", line 1042, in _validate_conn
    conn.connect()
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/snowflake/connector/vendored/urllib3/connection.py", line 414, in connect
    self.sock = ssl_wrap_socket(
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/snowflake/connector/ssl_wrap_socket.py", line 78, in ssl_wrap_socket_with_ocsp
    from .ocsp_asn1crypto import SnowflakeOCSPAsn1Crypto as SFOCSP
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/snowflake/connector/ocsp_asn1crypto.py", line 47, in <module>
    from snowflake.connector.ocsp_snowflake import SnowflakeOCSP
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/snowflake/connector/ocsp_snowflake.py", line 71, in <module>
    from .cache import SFDictCache
  File "/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/snowflake/connector/cache.py", line 12, in <module>
    from typing_extensions import NamedTuple, Self
ImportError: cannot import name 'NamedTuple' from 'typing_extensions' (/home/runner/lpgetsold2/venv/lib/python3.8/site-packages/typing_extensions.py)

Try after running in Shell:

poetry update replit

replit package had, for very long, an outdated typing-extensions dependency.


oh, so you’re using the python 3.8 template now. Note that the steps to solving your problem probably work on normal 3.10 as well if you ever want

1 Like

I’m ok to migrate the code to a different version. Just pretty new to all of this and need some hand holding LOL.

Thanks for reminding me, I’ll update the 3.8 template in a bit.

Edit: I actually updated it within ~10 minutes of posting that, and did an overall poetry update as well, I just forgot to update here.

1 Like

Ok I’ve migrated back to my original file running 3.10. and it’s starting to run! But now I’m getting the following:

Traceback (most recent call last):
  File "main.py", line 134, in <module>
    main()
  File "main.py", line 127, in main
    with engine.connect() as con:
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3325, in connect
    return self._connection_cls(self, close_with_result=close_with_result)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 96, in __init__
    else engine.raw_connection()
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3404, in raw_connection
    return self._wrap_pool_connect(self.pool.connect, _connection)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3371, in _wrap_pool_connect
    return fn()
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 327, in connect
    return _ConnectionFairy._checkout(self)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 894, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 493, in checkout
    rec = pool._do_get()
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 145, in _do_get
    with util.safe_reraise():
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 143, in _do_get
    return self._create_connection()
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 273, in _create_connection
    return _ConnectionRecord(self)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 388, in __init__
    self.__connect()
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 690, in __connect
    with util.safe_reraise():
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 686, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 574, in connect
    return dialect.connect(*cargs, **cparams)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/sqlalchemy/snowdialect.py", line 854, in connect
    super().connect(
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 598, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/__init__.py", line 51, in Connect
    return SnowflakeConnection(**kwargs)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/connection.py", line 302, in __init__
    self.connect(**kwargs)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/connection.py", line 566, in connect
    self.__open_connection()
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/connection.py", line 819, in __open_connection
    self.authenticate_with_retry(self.auth_class)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/connection.py", line 1075, in authenticate_with_retry
    self._authenticate(auth_instance)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/connection.py", line 1096, in _authenticate
    auth.authenticate(
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/auth/_auth.py", line 250, in authenticate
    ret = self._rest._post_request(
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/network.py", line 704, in _post_request
    ret = self.fetch(
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/network.py", line 802, in fetch
    ret = self._request_exec_wrapper(
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/network.py", line 925, in _request_exec_wrapper
    raise e
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/network.py", line 845, in _request_exec_wrapper
    return_object = self._request_exec(
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/network.py", line 1124, in _request_exec
    raise err
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/network.py", line 1026, in _request_exec
    raw_ret = session.request(
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/vendored/requests/sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/vendored/requests/sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/vendored/requests/adapters.py", line 489, in send
    resp = conn.urlopen(
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py", line 1042, in _validate_conn
    conn.connect()
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/vendored/urllib3/connection.py", line 414, in connect
    self.sock = ssl_wrap_socket(
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/ssl_wrap_socket.py", line 78, in ssl_wrap_socket_with_ocsp
    from .ocsp_asn1crypto import SnowflakeOCSPAsn1Crypto as SFOCSP
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/ocsp_asn1crypto.py", line 60, in <module>
    from oscrypto import asymmetric
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/oscrypto/asymmetric.py", line 19, in <module>
    from ._asymmetric import _unwrap_private_key_info
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/oscrypto/_asymmetric.py", line 27, in <module>
    from .kdf import pbkdf1, pbkdf2, pkcs12_kdf
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/oscrypto/kdf.py", line 9, in <module>
    from .util import rand_bytes
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/oscrypto/util.py", line 14, in <module>
    from ._openssl.util import rand_bytes
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/oscrypto/_openssl/util.py", line 6, in <module>
    from ._libcrypto import libcrypto, libcrypto_version_info, handle_openssl_error
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/oscrypto/_openssl/_libcrypto.py", line 9, in <module>
    from ._libcrypto_cffi import (
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/oscrypto/_openssl/_libcrypto_cffi.py", line 27, in <module>
    raise LibraryNotFoundError('The library libcrypto could not be found')
oscrypto.errors.LibraryNotFoundError: The library libcrypto could not be found

I tried poetry add libcrypto and got the following returned:

Traceback (most recent call last):
  File "main.py", line 134, in <module>
    main()
  File "main.py", line 127, in main
    with engine.connect() as con:
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3325, in connect
    return self._connection_cls(self, close_with_result=close_with_result)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 96, in __init__
    else engine.raw_connection()
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3404, in raw_connection
    return self._wrap_pool_connect(self.pool.connect, _connection)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3371, in _wrap_pool_connect
    return fn()
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 327, in connect
    return _ConnectionFairy._checkout(self)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 894, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 493, in checkout
    rec = pool._do_get()
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 145, in _do_get
    with util.safe_reraise():
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 143, in _do_get
    return self._create_connection()
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 273, in _create_connection
    return _ConnectionRecord(self)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 388, in __init__
    self.__connect()
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 690, in __connect
    with util.safe_reraise():
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 686, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 574, in connect
    return dialect.connect(*cargs, **cparams)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/sqlalchemy/snowdialect.py", line 854, in connect
    super().connect(
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 598, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/__init__.py", line 51, in Connect
    return SnowflakeConnection(**kwargs)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/connection.py", line 302, in __init__
    self.connect(**kwargs)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/connection.py", line 566, in connect
    self.__open_connection()
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/connection.py", line 819, in __open_connection
    self.authenticate_with_retry(self.auth_class)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/connection.py", line 1075, in authenticate_with_retry
    self._authenticate(auth_instance)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/connection.py", line 1096, in _authenticate
    auth.authenticate(
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/auth/_auth.py", line 250, in authenticate
    ret = self._rest._post_request(
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/network.py", line 704, in _post_request
    ret = self.fetch(
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/network.py", line 802, in fetch
    ret = self._request_exec_wrapper(
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/network.py", line 925, in _request_exec_wrapper
    raise e
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/network.py", line 845, in _request_exec_wrapper
    return_object = self._request_exec(
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/network.py", line 1124, in _request_exec
    raise err
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/network.py", line 1026, in _request_exec
    raw_ret = session.request(
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/vendored/requests/sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/vendored/requests/sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/vendored/requests/adapters.py", line 489, in send
    resp = conn.urlopen(
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py", line 1042, in _validate_conn
    conn.connect()
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/vendored/urllib3/connection.py", line 414, in connect
    self.sock = ssl_wrap_socket(
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/ssl_wrap_socket.py", line 78, in ssl_wrap_socket_with_ocsp
    from .ocsp_asn1crypto import SnowflakeOCSPAsn1Crypto as SFOCSP
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/snowflake/connector/ocsp_asn1crypto.py", line 60, in <module>
    from oscrypto import asymmetric
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/oscrypto/asymmetric.py", line 19, in <module>
    from ._asymmetric import _unwrap_private_key_info
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/oscrypto/_asymmetric.py", line 27, in <module>
    from .kdf import pbkdf1, pbkdf2, pkcs12_kdf
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/oscrypto/kdf.py", line 9, in <module>
    from .util import rand_bytes
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/oscrypto/util.py", line 14, in <module>
    from ._openssl.util import rand_bytes
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/oscrypto/_openssl/util.py", line 6, in <module>
    from ._libcrypto import libcrypto, libcrypto_version_info, handle_openssl_error
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/oscrypto/_openssl/_libcrypto.py", line 9, in <module>
    from ._libcrypto_cffi import (
  File "/home/runner/lpgetsold/venv/lib/python3.10/site-packages/oscrypto/_openssl/_libcrypto_cffi.py", line 27, in <module>
    raise LibraryNotFoundError('The library libcrypto could not be found')
oscrypto.errors.LibraryNotFoundError: The library libcrypto could not be found

Also I’ve updated snowflake-sqlalchemy, snowflake-connector-python, and sqlalchemy to the most recent version

If you open the Console tab, what happens if you run import libcrypto?
Actually, reading this error:

After doing a bit of research, this might be an OOM (Out Of Memory) error. see:

libcrypto is provided by openSSL.
When a library needed for a Python package is missing, you add the Nix package to the makeLibraryPath array in replit.nix and use the lib output if available, or, if not (like in this case), the out output. Here you could do this by running in Shell

sed -i '/    ];/i\      pkgs.openssl.out' replit.nix
1 Like

Question:
Keep on getting the following error when running my code:

raise LibraryNotFoundError('The library libcrypto could not be found')
oscrypto.errors.LibraryNotFoundError: The library libcrypto could not be found

Repl link:
https://replit.com/@KirkHolmes/lpgetsold

New to this and finally got everything running but I even took out all of the version dependencies in my requirements.txt file and I’m still getting the error after reinstalling all requirements. Since I’m new to the platform I may not be able to engage as much as I’d like due to a 20 message a day limit. I’ve also tried with pip and poetry to install libcrypto and some other libraries that I’ve found that use it to no avail. The programs objective is to perform an API call, transform/modify it and then store the results in a snowflake database via sqlalchemy. From looking at the error it looks like it’s an issue with sqlalchemy’s snowflake connector something to that effect.

@KirkHolmes Try what @UMARismyname suggested please.

Trying something similar with snowflake connector and got the same msg on oscrypto.errors.LibraryNotFoundError: The library libcrypto could not be found. Tried poetry add libcrypto and pip install libcrypto but to no avail. it runs file on my local machine with python 3.11 also.

Would love to hear what’s the final solution that worked out. @KirkHolmes @UMARismyname

It’s not something that can be pip installed (it’s an OS library, not a package), so @UMARismyname’a command here should work:

1 Like

yea tried this but still got the same error:

~/Prophet$ sed -i '/    ];/i\      pkgs.openssl.out' replit.nix
Detected change in environment, reloading shell...

~/Prophet$ 
~/Prophet$ python snow.py
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/oscrypto/_openssl/_libcrypto_cffi.py", line 27, in <module>
    raise LibraryNotFoundError('The library libcrypto could not be found')
oscrypto.errors.LibraryNotFoundError: The library libcrypto could not be found

or is it possible to set a new environment in replit for me to test out? i can run this fine on my local machine… @Firepup650 @UMARismyname

for new modules-based Python repls (I can tell yours is one because of .pythonlibs):

  1. Create a new tab to open the replit.nix file
  2. Add before the final }
  env = {
    LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
      pkgs.openssl.out
    ];
  };
2 Likes

thanks @UMARismyname ! have added and the replit.nix now looks like:

{ pkgs }: {
  deps = [
  ];
  env = {
  LD_LIBRARY_PATH = pkgs.openssl.out;
  };
}

the problem though still persists after saving this file (checked):

~/Prophet$ python snow.py
Traceback (most recent call last):
  File "/home/runner/Prophet/snow.py", line 10, in <module>
    con = snowflake.connector.connect(user=snow_user,
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/snowflake/connector/__init__.py", line 54, in Connect
    return SnowflakeConnection(**kwargs)
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/snowflake/connector/connection.py", line 372, in __init__
    self.connect(**kwargs)
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/snowflake/connector/connection.py", line 644, in connect
    self.__open_connection()
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/snowflake/connector/connection.py", line 917, in __open_connection
    self.authenticate_with_retry(self.auth_class)
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/snowflake/connector/connection.py", line 1186, in authenticate_with_retry
    self._authenticate(auth_instance)
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/snowflake/connector/connection.py", line 1212, in _authenticate
    auth.authenticate(
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/snowflake/connector/auth/_auth.py", line 250, in authenticate
    ret = self._rest._post_request(
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/snowflake/connector/network.py", line 730, in _post_request
    ret = self.fetch(
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/snowflake/connector/network.py", line 849, in fetch
    ret = self._request_exec_wrapper(
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/snowflake/connector/network.py", line 987, in _request_exec_wrapper
    raise e
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/snowflake/connector/network.py", line 891, in _request_exec_wrapper
    return_object = self._request_exec(
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/snowflake/connector/network.py", line 1189, in _request_exec
    raise err
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/snowflake/connector/network.py", line 1084, in _request_exec
    raw_ret = session.request(
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/snowflake/connector/vendored/requests/sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/snowflake/connector/vendored/requests/sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/snowflake/connector/vendored/requests/adapters.py", line 487, in send
    resp = conn.urlopen(
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py", line 1042, in _validate_conn
    conn.connect()
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/snowflake/connector/vendored/urllib3/connection.py", line 419, in connect
    self.sock = ssl_wrap_socket(
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/snowflake/connector/ssl_wrap_socket.py", line 85, in ssl_wrap_socket_with_ocsp
    from .ocsp_asn1crypto import SnowflakeOCSPAsn1Crypto as SFOCSP
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/snowflake/connector/ocsp_asn1crypto.py", line 62, in <module>
    from oscrypto import asymmetric
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/oscrypto/asymmetric.py", line 19, in <module>
    from ._asymmetric import _unwrap_private_key_info
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/oscrypto/_asymmetric.py", line 27, in <module>
    from .kdf import pbkdf1, pbkdf2, pkcs12_kdf
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/oscrypto/kdf.py", line 9, in <module>
    from .util import rand_bytes
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/oscrypto/util.py", line 14, in <module>
    from ._openssl.util import rand_bytes
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/oscrypto/_openssl/util.py", line 6, in <module>
    from ._libcrypto import libcrypto, libcrypto_version_info, handle_openssl_error
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/oscrypto/_openssl/_libcrypto.py", line 9, in <module>
    from ._libcrypto_cffi import (
  File "/home/runner/Prophet/.pythonlibs/lib/python3.10/site-packages/oscrypto/_openssl/_libcrypto_cffi.py", line 27, in <module>
    raise LibraryNotFoundError('The library libcrypto could not be found')
oscrypto.errors.LibraryNotFoundError: The library libcrypto could not be found

oops, I’ve edited my post. Try that

1 Like