简体   繁体   中英

How to use OpenSSL in Python 3.7 in FreeBSD?

My Python code is using a module that uses OpenSSL. I'm running on a shared FreeBSD server.

When I try to run my code, I'm getting the error below. After researching, I thought that it was due to openssl-devel not being installed.

However, I've been informed that FreeBSD does not separate libraries and headers into separate packages the way Linux does. The headers for OpenSSL are found in /usr/local/include/openssl and OPENSSL_no_config is defined in conf.h.

What do I need to do for my code to recognize that the headers are in this location?

Thank you!

...
  File "<virtual environment path>/lib/python3.7/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 16, in <module>
    from cryptography.hazmat.bindings._openssl import ffi, lib
ImportError: <virtual environment path>/lib/python3.7/site-packages/cryptography/hazmat/bindings/_openssl.abi3.so: Undefined symbol "OPENSSL_no_config"

Edit: After doing more digging, I thought rebuilding my virtual environment and specifying these additional parameters would help when installing the libraries, but I faced the same error.

pip install --global-option=build_ext  --global-option="-I/usr/local/include/openssl"  -r requirements.txt

This pip install command ended up working (in my original post I had included /openssl in the include directory and it was not needed):

pip install --global-option=build_ext --global-option="-I/usr/local/include/" -r requirements.txt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM