ModuleNotFound for SQLAlchemy and Snowflake Database

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