0

I'm trying to install python-binance libs on my MacBook M1 (learning python and crypto)... had same kind of issues with TA-Lib but fixed that with brew install I keep getting

    renaatvandewiele@Renaats-MBP Pythontrade % sudo -H python3.9 -m pip install python-binance             Password: Collecting python-binance Using cached python_binance-0.7.9-py2.py3-none-any.whl (36 kB) Requirement already satisfied: requests in /opt/homebrew/lib/python3.9/site-packages (from python-binance) (2.25.1) Collecting service-identity   Using cached service_identity-18.1.0-py2.py3-none-any.whl (11 kB) Collecting cryptography   Using cached cryptography-3.4.6.tar.gz (546 kB)   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/python@3.9/bin/python3.9 /opt/homebrew/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmp9xr5jjee
             cwd: /private/tmp/pip-install-nvlbt5or/cryptography_372649a7a69d4e9ab469653b0c8c59e7
        Complete output (58 lines):

    
        =============================DEBUG ASSISTANCE=============================
        If you are seeing a compilation error please try the following steps to
        successfully install cryptography:
        1) Upgrade to the latest pip and try again. This will fix errors for most
           users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip
        2) Read https://cryptography.io/en/latest/installation.html for specific
           instructions for your platform.
        3) Check our frequently asked questions for more information:
           https://cryptography.io/en/latest/faq.html
        4) Ensure you have a recent Rust toolchain installed:
           https://cryptography.io/en/latest/installation.html#rust
        5) If you are experiencing issues with Rust for *this release only* you may
           set the environment variable `CRYPTOGRAPHY_DONT_BUILD_RUST=1`.
        =============================DEBUG ASSISTANCE=============================
    

    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/tmp/pip-build-env-kijhr80e/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 161, in prepare_metadata_for_build_wheel
        self.run_setup()
      File "/private/tmp/pip-build-env-kijhr80e/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 71, in <module>
        setup(
      File "/private/tmp/pip-build-env-kijhr80e/overlay/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup
        return distutils.core.setup(**attrs)
      File "/opt/homebrew/Cellar/python@3.9/3.9.1_8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/core.py", line 108, in setup
        _setup_distribution = dist = klass(attrs)
      File "/private/tmp/pip-build-env-kijhr80e/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 432, in __init__
        _Distribution.__init__(self, {
      File "/opt/homebrew/Cellar/python@3.9/3.9.1_8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 292, in __init__
        self.finalize_options()
      File "/private/tmp/pip-build-env-kijhr80e/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 708, in finalize_options
        ep(self)
      File "/private/tmp/pip-build-env-kijhr80e/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 715, in _finalize_setup_keywords
        ep.load()(self, ep.name, value)
      File "/private/tmp/pip-build-env-kijhr80e/overlay/lib/python3.9/site-packages/cffi/setuptools_ext.py", line 219, in cffi_modules
        add_cffi_module(dist, cffi_module)
      File "/private/tmp/pip-build-env-kijhr80e/overlay/lib/python3.9/site-packages/cffi/setuptools_ext.py", line 49, in add_cffi_module
        execfile(build_file_name, mod_vars)
      File "/private/tmp/pip-build-env-kijhr80e/overlay/lib/python3.9/site-packages/cffi/setuptools_ext.py", line 25, in execfile
        exec(code, glob, glob)
      File "src/_cffi_src/build_openssl.py", line 76, in <module>
        ffi = build_ffi_for_binding(
      File "src/_cffi_src/utils.py", line 53, in build_ffi_for_binding
        ffi = build_ffi(
      File "src/_cffi_src/utils.py", line 73, in build_ffi
        ffi = FFI()
      File "/private/tmp/pip-build-env-kijhr80e/overlay/lib/python3.9/site-packages/cffi/api.py", line 48, in __init__
        import _cffi_backend as backend
    ImportError: dlopen(/private/tmp/pip-build-env-kijhr80e/overlay/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so, 2): no suitable image found.  Did find:
        /private/tmp/pip-build-env-kijhr80e/overlay/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so: mach-o, but wrong architecture
        /private/tmp/pip-build-env-kijhr80e/overlay/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so: mach-o, but wrong architecture
    ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/fa/2d/2154d8cb773064570f48ec0b60258a4522490fcb115a6c7c9423482ca993/cryptography-3.4.6.tar.gz#sha256=2d32223e5b0ee02943f32b19245b61a62db83a882f0e76cc564e1cec60d48f87 (from https://pypi.org/simple/cryptography/) (requires-python:>=3.6). Command errored out with exit status 1: /opt/homebrew/opt/python@3.9/bin/python3.9 /opt/homebrew/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmp9xr5jjee Check the logs for full command output.
  Using cached cryptography-3.4.5.tar.gz (546 kB)
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
  • 1
    What happens if you run it without sudo? You shouldn't need elevated permissions to install pip packages. You can mess up your system like this. – forgetso Feb 17 '21 at 10:07
  • I get the same error but also 1jtv8nx/overlay/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so: mach-o, but wrong architecture /private/var/folders/pr/wm97vv7x37q534rww195lxt80000gn/T/pip-build-env-j1jtv8nx/overlay/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so: mach-o, but wrong architecture – Renaat Vandewiele Feb 17 '21 at 11:01
  • Have you tried the steps listed in the output? - "Upgrade to the latest pip and try again." – forgetso Feb 17 '21 at 11:27
  • renaatvandewiele@Renaats-MBP Pythontrade % python3.9 -m pip install -U pip Requirement already satisfied: pip in /opt/homebrew/lib/python3.9/site-packages (21.0.1) – Renaat Vandewiele Feb 17 '21 at 11:47
  • Suggestion [here](https://stackoverflow.com/questions/25439212/building-pyspotify-in-32bit-python-osx-mavericks) is to try installing gcc, libffi using homebrew. `brew install gcc` and `brew install libffi` – forgetso Feb 17 '21 at 12:26
  • sadly that did not do it :( – Renaat Vandewiele Feb 17 '21 at 13:35
  • There are other steps in the output, e.g. "Ensure you have a recent Rust toolchain installed: https://cryptography.io/en/latest/installation.html#rust" – forgetso Feb 17 '21 at 13:44

1 Answers1

0

cryptography does not currently ship an arm64 macOS wheel (due to no CI being available). To install it successfully you will need to follow the instructions here: https://cryptography.io/en/latest/installation.html#building-cryptography-on-macos

Paul Kehrer
  • 13,466
  • 4
  • 40
  • 57