ImportError: Symbol not found: _ffi_prep_closure on Apple Silicon with CPython 3.9.6
System: macOS Big Sur 11.5 (Apple Silicon)
Python: CPython 3.9.6 installed by pyenv. (Configure flags: --with-dtrace --with-framework --enable-optimizations --with-ensurepip=upgrade)
CFFI VERSION: 1.14.6
Package Management:
poetry 1.1.7
pip 21.2.2
setuptools 57.0.0
Steps
pip install bcrypt
Expect
Installation success.
Actual
$ python -VV
Python 3.9.6 (default, Jul 12 2021, 18:23:45)
[Clang 12.0.5 (clang-1205.0.22.9)]
$ pip install bcrypt -U
Collecting bcrypt
Using cached bcrypt-3.2.0.tar.gz (42 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... error
ERROR: Command errored out with exit status 1:
command: /Users/User/Library/Caches/pypoetry/virtualenvs/athena-KNwCPsJq-py3.9/bin/python /Users/User/Library/Caches/pypoetry/virtualenvs/athena-KNwCPsJq-py3.9/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py prepare_metadata_for_build_wheel /var/folders/5s/8rczg1gs4wb59y9s22nc3f_r0000gn/T/tmp74wwwf_q
cwd: /private/var/folders/5s/8rczg1gs4wb59y9s22nc3f_r0000gn/T/pip-install-azxktwnp/bcrypt_892886653fab43e190fa3b13d0dcd69b
Complete output (39 lines):
Traceback (most recent call last):
File "/Users/User/Library/Caches/pypoetry/virtualenvs/athena-KNwCPsJq-py3.9/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 349, in <module>
main()
File "/Users/User/Library/Caches/pypoetry/virtualenvs/athena-KNwCPsJq-py3.9/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 331, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/Users/User/Library/Caches/pypoetry/virtualenvs/athena-KNwCPsJq-py3.9/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 151, in prepare_metadata_for_build_wheel
return hook(metadata_directory, config_settings)
File "/private/var/folders/5s/8rczg1gs4wb59y9s22nc3f_r0000gn/T/pip-build-env-ka92635y/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 166, in prepare_metadata_for_build_wheel
self.run_setup()
File "/private/var/folders/5s/8rczg1gs4wb59y9s22nc3f_r0000gn/T/pip-build-env-ka92635y/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 150, in run_setup
exec(compile(code, __file__, 'exec'), locals())
File "setup.py", line 46, in <module>
setup(
File "/private/var/folders/5s/8rczg1gs4wb59y9s22nc3f_r0000gn/T/pip-build-env-ka92635y/overlay/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup
return distutils.core.setup(**attrs)
File "/Users/User/.pyenv/versions/3.9.6/lib/python3.9/distutils/core.py", line 108, in setup
_setup_distribution = dist = klass(attrs)
File "/private/var/folders/5s/8rczg1gs4wb59y9s22nc3f_r0000gn/T/pip-build-env-ka92635y/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 455, in __init__
_Distribution.__init__(self, {
File "/Users/User/.pyenv/versions/3.9.6/lib/python3.9/distutils/dist.py", line 292, in __init__
self.finalize_options()
File "/private/var/folders/5s/8rczg1gs4wb59y9s22nc3f_r0000gn/T/pip-build-env-ka92635y/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 807, in finalize_options
ep(self)
File "/private/var/folders/5s/8rczg1gs4wb59y9s22nc3f_r0000gn/T/pip-build-env-ka92635y/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 814, in _finalize_setup_keywords
ep.load()(self, ep.name, value)
File "/private/var/folders/5s/8rczg1gs4wb59y9s22nc3f_r0000gn/T/pip-build-env-ka92635y/overlay/lib/python3.9/site-packages/cffi/setuptools_ext.py", line 219, in cffi_modules
add_cffi_module(dist, cffi_module)
File "/private/var/folders/5s/8rczg1gs4wb59y9s22nc3f_r0000gn/T/pip-build-env-ka92635y/overlay/lib/python3.9/site-packages/cffi/setuptools_ext.py", line 49, in add_cffi_module
execfile(build_file_name, mod_vars)
File "/private/var/folders/5s/8rczg1gs4wb59y9s22nc3f_r0000gn/T/pip-build-env-ka92635y/overlay/lib/python3.9/site-packages/cffi/setuptools_ext.py", line 25, in execfile
exec(code, glob, glob)
File "src/build_bcrypt.py", line 21, in <module>
ffi = FFI()
File "/private/var/folders/5s/8rczg1gs4wb59y9s22nc3f_r0000gn/T/pip-build-env-ka92635y/overlay/lib/python3.9/site-packages/cffi/api.py", line 48, in __init__
import _cffi_backend as backend
ImportError: dlopen(/private/var/folders/5s/8rczg1gs4wb59y9s22nc3f_r0000gn/T/pip-build-env-ka92635y/overlay/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so, 2): Symbol not found: _ffi_prep_closure
Referenced from: /private/var/folders/5s/8rczg1gs4wb59y9s22nc3f_r0000gn/T/pip-build-env-ka92635y/overlay/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so
Expected in: flat namespace
in /private/var/folders/5s/8rczg1gs4wb59y9s22nc3f_r0000gn/T/pip-build-env-ka92635y/overlay/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so
----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/d8/ba/21c475ead997ee21502d30f76fd93ad8d5858d19a3fad7cd153de698c4dd/bcrypt-3.2.0.tar.gz#sha256=5b93c1726e50a93a033c36e5ca7fdcd29a5c7395af50a6892f5d9e7c6cfbfb29 (from https://pypi.org/simple/bcrypt/) (requires-python:>=3.6). Command errored out with exit status 1: /Users/User/Library/Caches/pypoetry/virtualenvs/athena-KNwCPsJq-py3.9/bin/python /Users/User/Library/Caches/pypoetry/virtualenvs/athena-KNwCPsJq-py3.9/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py prepare_metadata_for_build_wheel /var/folders/5s/8rczg1gs4wb59y9s22nc3f_r0000gn/T/tmp74wwwf_q Check the logs for full command output.
Edited by Kevin Lee