Repository navigation
Closed
Description
Trying to pip3 install pynacl on an M1 Mac with pip3 version 20.3.3.
Get this message on install - any ideas?
Other libs are working ok, such as tinyec.
Collecting pynacl
Downloading PyNaCl-1.4.0.tar.gz (3.4 MB)
|████████████████████████████████| 3.4 MB 1.8 MB/s
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... error
ERROR: Command errored out with exit status 1:
command: /opt/homebrew/opt/[email protected]/bin/python3.9 /opt/homebrew/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /var/folders/ws/4b7t11z91pv_wqpqd6dl21x40000gn/T/tmpyxshsvrm
cwd: /private/var/folders/ws/4b7t11z91pv_wqpqd6dl21x40000gn/T/pip-install-48_63pd2/pynacl_34f24b5a9a4045dfbb49726500e88931
Complete output (39 lines):
Traceback (most recent call last):
File "/opt/homebrew/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
main()
File "/opt/homebrew/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/opt/homebrew/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 133, in prepare_metadata_for_build_wheel
return hook(metadata_directory, config_settings)
File "/private/var/folders/ws/4b7t11z91pv_wqpqd6dl21x40000gn/T/pip-build-env-btqme7ob/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 161, in prepare_metadata_for_build_wheel
self.run_setup()
File "/private/var/folders/ws/4b7t11z91pv_wqpqd6dl21x40000gn/T/pip-build-env-btqme7ob/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 145, in run_setup
exec(compile(code, __file__, 'exec'), locals())
File "setup.py", line 216, in <module>
setup(
File "/private/var/folders/ws/4b7t11z91pv_wqpqd6dl21x40000gn/T/pip-build-env-btqme7ob/overlay/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup
return distutils.core.setup(**attrs)
File "/opt/homebrew/Cellar/[email protected]/3.9.1_6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/core.py", line 108, in setup
_setup_distribution = dist = klass(attrs)
File "/private/var/folders/ws/4b7t11z91pv_wqpqd6dl21x40000gn/T/pip-build-env-btqme7ob/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 432, in __init__
_Distribution.__init__(self, {
File "/opt/homebrew/Cellar/[email protected]/3.9.1_6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 292, in __init__
self.finalize_options()
File "/private/var/folders/ws/4b7t11z91pv_wqpqd6dl21x40000gn/T/pip-build-env-btqme7ob/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 708, in finalize_options
ep(self)
File "/private/var/folders/ws/4b7t11z91pv_wqpqd6dl21x40000gn/T/pip-build-env-btqme7ob/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 715, in _finalize_setup_keywords
ep.load()(self, ep.name, value)
File "/private/var/folders/ws/4b7t11z91pv_wqpqd6dl21x40000gn/T/pip-build-env-btqme7ob/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/ws/4b7t11z91pv_wqpqd6dl21x40000gn/T/pip-build-env-btqme7ob/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/ws/4b7t11z91pv_wqpqd6dl21x40000gn/T/pip-build-env-btqme7ob/overlay/lib/python3.9/site-packages/cffi/setuptools_ext.py", line 25, in execfile
exec(code, glob, glob)
File "src/bindings/build.py", line 36, in <module>
ffi = FFI()
File "/private/var/folders/ws/4b7t11z91pv_wqpqd6dl21x40000gn/T/pip-build-env-btqme7ob/overlay/lib/python3.9/site-packages/cffi/api.py", line 48, in __init__
import _cffi_backend as backend
ImportError: dlopen(/private/var/folders/ws/4b7t11z91pv_wqpqd6dl21x40000gn/T/pip-build-env-btqme7ob/overlay/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so, 2): Symbol not found: _ffi_prep_closure
Referenced from: /private/var/folders/ws/4b7t11z91pv_wqpqd6dl21x40000gn/T/pip-build-env-btqme7ob/overlay/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so
Expected in: flat namespace
in /private/var/folders/ws/4b7t11z91pv_wqpqd6dl21x40000gn/T/pip-build-env-btqme7ob/overlay/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so
----------------------------------------
ERROR: Command errored out with exit status 1: /opt/homebrew/opt/[email protected]/bin/python3.9 /opt/homebrew/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /var/folders/ws/4b7t11z91pv_wqpqd6dl21x40000gn/T/tmpyxshsvrm Check the logs for full command output.
This is what I have installed:
Package Version
------------ -------
meson 0.56.2
pip 20.3.3
protobuf 3.14.0
pycrypto 2.6.1
pycryptodome 3.9.9
setuptools 51.1.1
six 1.15.0
tinyec 0.3.1
wheel 0.36.2
Reacted by Matthieu Bizien, Phil Winder, Malte Gerth, Alex, fuomag9, Guiomar Valderrama and ytyng
Metadata
Metadata
Assignees
Labels
No labels
Activity
reaperhulk commentedon Jan 18, 2021
Building pynacl in a venv using M1 native homebrew python3.9 works on my M1 test machine.
This, unfortunately, makes it highly like that your issue is some type of environment problem specific to your circumstances. The error suggests symbol issues in cffi so you may want to try separately installing cffi first, or reinstalling it using --no-binary cffi to make it recompile in case you have a cached wheel compiled against a non-existent dylib. If you're not installing in a venv try making a new one and installing there as well.
ice29 commentedon Jan 19, 2021
I have the same problem on my M1... bcrypt also fails with exactly the same error.
Tried to install cffi or install it with no-binary, no help...
reaperhulk commentedon Jan 19, 2021
What happens if you run this command:
_ffi_prep_closureis an interesting symbol since it doesn't exist in my symbol table for_cffi_backend.cpython-39-darwin.soand yet no issues occur on my machine.ice29 commentedon Jan 19, 2021
The same problem comes up, but it is apparently known issue with CFFI
https://foss.heptapod.net/pypy/cffi/-/issues/464#note_147550
other libs have the same problem, e.g.
gevent/gevent#1721
johnalanwoods commentedon Jan 19, 2021
Maybe it's working for @reaperhulk because he's using x86 arch in terminal/rosetta?
ice29 commentedon Jan 19, 2021
yes, I have just setup rosetta2 x86_64 python3 and it works with that one...
johnalanwoods commentedon Jan 19, 2021
@ice29, I guess it will work in time so...
reaperhulk commentedon Jan 19, 2021
I bought this M1 mac specifically to test against arm64 for PyCA projects so my entire Python toolchain (and everything I use to test pynacl, bcrypt, and cryptography) is M1 native and not run through rosetta 2 😄
Given the amount of state inherent in a C build toolchain it's possible I did something (that I've now forgotten) to make this all work I suppose.
eblume commentedon May 27, 2021
@reaperhulk I am unfortunately still getting this error on my m1 mac. I am also in the process of filing a 'downstream' bug report with the Fabric team, as
pip install fabriccurrently fails on installing pynacl as a dependency due to this bug,fabricis a developer dependency in my project which means that I'm not presently able to even install my development environment on m1.Note: I am NOT using rosetta2.
reaperhulk commentedon May 27, 2021
@eblume What happens if you uninstall cffi and then attempt to install it with
LDFLAGS=-L$(brew --prefix libffi)/lib CFLAGS=-I$(brew --prefix libffi)/include pip install cffi --no-binary :all:? The problem you're seeing is a mismatch between the libffi cffi compiled against and the one it's finding at runtime. This typically occurs when it compiles against homebrew and then attempts to load the system libffi.eblume commentedon May 27, 2021
I also tried with replacing the last command with simply
pip install pynacl- same effect.bates64 commentedon Aug 18, 2021
I was able to install using the following setup:
carlosonunez commentedon Nov 8, 2021
If the previous solution isn't working for you, add
CPPFLAGS="-I /opt/homebrew/Cellar/libsodium/1.0.18_1/include"to the beginning ofpip install.reaperhulk commentedon Jan 7, 2022
We ship a universal2 wheel now.