wbond / oscrypto

Compiler-free Python crypto library backed by the OS, supporting CPython and PyPy
MIT License
320 stars 70 forks source link

Unable to load lib file when using Conda virtual environment #41

Closed chunheisiu closed 4 years ago

chunheisiu commented 4 years ago

I am on macOS Catalina and Python 3.7. While on Conda base, the application runs without errors. However, running it in a Conda virtual environment results in the following error.

Traceback (most recent call last):
  File "/Users/charles.siu/git/domain_classifier_real_estate/data_collector/server.py", line 7, in <module>
    from data_collector.domain import parse_train_domains, parse_predict_domains
  File "/Users/charles.siu/git/domain_classifier_real_estate/data_collector/domain.py", line 7, in <module>
    from data_collector.cert import get_cert, get_cert_issuer
  File "/Users/charles.siu/git/domain_classifier_real_estate/data_collector/cert.py", line 6, in <module>
    import oscrypto.asymmetric
  File "/usr/local/anaconda3/envs/domain_classifier/lib/python3.7/site-packages/oscrypto/asymmetric.py", line 19, in <module>
    from ._asymmetric import _unwrap_private_key_info
  File "/usr/local/anaconda3/envs/domain_classifier/lib/python3.7/site-packages/oscrypto/_asymmetric.py", line 27, in <module>
    from .kdf import pbkdf1, pbkdf2, pkcs12_kdf
  File "/usr/local/anaconda3/envs/domain_classifier/lib/python3.7/site-packages/oscrypto/kdf.py", line 9, in <module>
    from .util import rand_bytes
  File "/usr/local/anaconda3/envs/domain_classifier/lib/python3.7/site-packages/oscrypto/util.py", line 10, in <module>
    from ._mac.util import rand_bytes
  File "/usr/local/anaconda3/envs/domain_classifier/lib/python3.7/site-packages/oscrypto/_mac/util.py", line 208, in <module>
    from .._openssl._libcrypto import libcrypto
  File "/usr/local/anaconda3/envs/domain_classifier/lib/python3.7/site-packages/oscrypto/_openssl/_libcrypto.py", line 15, in <module>
    from ._libcrypto_ctypes import (
  File "/usr/local/anaconda3/envs/domain_classifier/lib/python3.7/site-packages/oscrypto/_openssl/_libcrypto_ctypes.py", line 37, in <module>
    libcrypto = CDLL(libcrypto_path, use_errno=True)
  File "/usr/local/anaconda3/envs/domain_classifier/lib/python3.7/ctypes/__init__.py", line 364, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(/usr/local/anaconda3/envs/domain_classifier/bin/../lib/libcrypto.42.dylib, 6): image not found

I have tried symbolic linking /usr/lib to ../lib but it seemed to have created more issues. Any help is appreciated!

wbond commented 4 years ago

I am not familiar with Conda virtual environments. Do they modify access to the filesystem somehow, or provide some sort of symlinked root folder structure?

chunheisiu commented 4 years ago

So instead of /usr/local/anaconda3/lib/, the virtual environment seems to have a separate lib directory, which does not contain the libcrypto.42.dylib in this case. I am happy to provide more information if it helps.

wbond commented 4 years ago

This should be fixed by c184e9013d280107d59f0622d6258b4813348fc8