randy3k / radian

A 21 century R console
MIT License
2k stars 76 forks source link

Big Sur Mac M1 - Radian Not Running #317

Closed HiramTheHero closed 2 years ago

HiramTheHero commented 2 years ago

Hello. I've read through the previous issues about this, but I am still not able to use radian.

Checking Python Architecture Version

➜  ~ which python3
/opt/homebrew/bin/python3
➜  ~ lipo /opt/homebrew/bin/python3 -info
Non-fat file: /opt/homebrew/bin/python3 is architecture: arm64

Check R Architecture Version

➜  ~ Which R
/opt/homebrew/bin/R
➜  ~ /opt/homebrew/bin/R

R version 4.1.1 (2021-08-10) -- "Kick Things"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin20.5.0 (64-bit)

Install radian

➜  ~  pip3 install --no-binary :all: radian
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
Collecting radian
  Using cached radian-0.5.12.tar.gz (49 kB)
Requirement already satisfied: rchitect<0.4.0,>=0.3.30 in /opt/homebrew/lib/python3.9/site-packages (from radian) (0.3.32)
Requirement already satisfied: lineedit<0.2.0,>=0.1.5 in /opt/homebrew/lib/python3.9/site-packages (from radian) (0.1.6)
Requirement already satisfied: six>=1.9.0 in /opt/homebrew/lib/python3.9/site-packages (from radian) (1.16.0)
Requirement already satisfied: pygments>=2.5.0 in /opt/homebrew/lib/python3.9/site-packages (from radian) (2.10.0)
Requirement already satisfied: wcwidth in /opt/homebrew/lib/python3.9/site-packages (from lineedit<0.2.0,>=0.1.5->radian) (0.2.5)
Collecting cffi>=1.10.0
  Using cached cffi-1.14.6.tar.gz (475 kB)
Requirement already satisfied: pycparser in /opt/homebrew/lib/python3.9/site-packages (from cffi>=1.10.0->rchitect<0.4.0,>=0.3.30->radian) (2.20)
Skipping wheel build for radian, due to binaries being disabled for it.
Skipping wheel build for cffi, due to binaries being disabled for it.
Installing collected packages: cffi, radian
    Running setup.py install for cffi ... done
    Running setup.py install for radian ... done
Successfully installed cffi-1.14.6 radian-0.5.12

Running Radian

➜  ~ radian
Traceback (most recent call last):
  File "/opt/homebrew/bin/radian", line 33, in <module>
    sys.exit(load_entry_point('radian==0.5.12', 'console_scripts', 'radian')())
  File "/opt/homebrew/lib/python3.9/site-packages/radian/__init__.py", line 11, in main
    from rchitect.utils import Rhome, rversion
  File "/opt/homebrew/lib/python3.9/site-packages/rchitect/__init__.py", line 1, in <module>
    from .setup import init, loop
  File "/opt/homebrew/lib/python3.9/site-packages/rchitect/setup.py", line 6, in <module>
    from rchitect._cffi import ffi, lib
ImportError: dlopen(/opt/homebrew/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so, 2): no suitable image found.  Did find:
    /opt/homebrew/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so: mach-o, but wrong architecture
    /opt/homebrew/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so: mach-o, but wrong architecture

From my novice perspective it looks like the wrong architecture version of cffi is being installed. But, I'm not sure how to get the right one. Please let me know what I need to do to remedy the situation. Thank you for your time and help.

randy3k commented 2 years ago

I vaguely recall that cffi used to have an issue of shipping a wrong binary. Try to uninstall cffi and install it from source.

pip3 uninstall cffi
pip3 install --no-binary :all: cffi
HiramTheHero commented 2 years ago

Thank you for the prompt reply. I tried as directed, but it did not work.

Cffi is uninstalled

➜  ~ pip3 uninstall cffi
WARNING: Skipping cffi as it is not installed.

Radian is uninstalled

➜  ~ pip3 uninstall radian
WARNING: Skipping radian as it is not installed.

Installing cffi from source.

➜  ~ pip3 install --no-binary :all: cffi
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
Collecting cffi
  Using cached cffi-1.14.6.tar.gz (475 kB)
Requirement already satisfied: pycparser in /opt/homebrew/lib/python3.9/site-packages (from cffi) (2.20)
Skipping wheel build for cffi, due to binaries being disabled for it.
Installing collected packages: cffi
    Running setup.py install for cffi ... done
Successfully installed cffi-1.14.6

Installing Radian from Source

➜  ~ pip3 install --no-binary :all: radian
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
Collecting radian
  Using cached radian-0.5.12.tar.gz (49 kB)
Requirement already satisfied: rchitect<0.4.0,>=0.3.30 in /opt/homebrew/lib/python3.9/site-packages (from radian) (0.3.32)
Requirement already satisfied: lineedit<0.2.0,>=0.1.5 in /opt/homebrew/lib/python3.9/site-packages (from radian) (0.1.6)
Requirement already satisfied: six>=1.9.0 in /opt/homebrew/lib/python3.9/site-packages (from radian) (1.16.0)
Requirement already satisfied: pygments>=2.5.0 in /opt/homebrew/lib/python3.9/site-packages (from radian) (2.10.0)
Requirement already satisfied: wcwidth in /opt/homebrew/lib/python3.9/site-packages (from lineedit<0.2.0,>=0.1.5->radian) (0.2.5)
Requirement already satisfied: cffi>=1.10.0 in /opt/homebrew/lib/python3.9/site-packages (from rchitect<0.4.0,>=0.3.30->radian) (1.14.6)
Requirement already satisfied: pycparser in /opt/homebrew/lib/python3.9/site-packages (from cffi>=1.10.0->rchitect<0.4.0,>=0.3.30->radian) (2.20)
Skipping wheel build for radian, due to binaries being disabled for it.
Installing collected packages: radian
    Running setup.py install for radian ... done
Successfully installed radian-0.5.12

Starting Radian with same error.

➜  ~ radian
Traceback (most recent call last):
  File "/opt/homebrew/bin/radian", line 33, in <module>
    sys.exit(load_entry_point('radian==0.5.12', 'console_scripts', 'radian')())
  File "/opt/homebrew/lib/python3.9/site-packages/radian/__init__.py", line 11, in main
    from rchitect.utils import Rhome, rversion
  File "/opt/homebrew/lib/python3.9/site-packages/rchitect/__init__.py", line 1, in <module>
    from .setup import init, loop
  File "/opt/homebrew/lib/python3.9/site-packages/rchitect/setup.py", line 6, in <module>
    from rchitect._cffi import ffi, lib
ImportError: dlopen(/opt/homebrew/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so, 2): no suitable image found.  Did find:
    /opt/homebrew/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so: mach-o, but wrong architecture
    /opt/homebrew/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so: mach-o, but wrong architecture

Thank you again for your time and help.

psobolewskiPhD commented 2 years ago

Hmm, I installed a while ago using the Apple python/pip3 tool chain (v 3.8), but with R from homebrew. For me that file is: lipo -info _cffi_backend.cpython-38-darwin.so

Architectures in the fat file: _cffi_backend.cpython-38-darwin.so are: x86_64 arm64 

I've not updated anything in a while, but here's my env:

Package    Version
---------- -------
cffi       1.14.4 
lineedit   0.1.5  
pip        19.2.3 
pycparser  2.20   
Pygments   2.7.3  
radian     0.5.9  
rchitect   0.3.29 
setuptools 41.2.0 
six        1.15.0 
wcwidth    0.2.5  
wheel      0.33.1 

Edit1: The only notes I have from my installation are:

  1. I needed to set: PYTHONDONTWRITEBYTECODE=1
  2. I cloned the radian github (but made no changes)
  3. install with --user Edit2: I do see I have libffi installed via homebrew, but I'm not sure that was part of the radian install. Still, I think this is a binary that's required by cffi so maybe you have a x86 version somewhere and that's the issue?
HiramTheHero commented 2 years ago

Thank you all for the help.

For some reason when I use pip3 install --no-binary :all: cffi it downloads the x84 version of _cffi_backend.cpython-38-darwin.so I wasn't sure how to specify which architecture to get from the command line interface, so I did the following.

I went to the webpage with python's cffi package (https://pypi.org/project/cffi/#files). And I downloaded the file cffi-1.15.0-cp39-cp39-macosx_11_0_arm64.whl (There are a couple files listed with "arm64" in the name of the file. I assume they go off of the version of python being used. Make sure you get the one for your version of python.)

Then I ran pip3 install /local/path/to/cffi-1.15.0-cp39-cp39-macosx_11_0_arm64.whl

Then I ran lipo -info /opt/homebrew/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so and got the output Non-fat file: /opt/homebrew/lib/python3.9/site-packages/_cffi_backend.cpython-39-darwin.so is architecture: arm64

I ran pip3 install radian and now it is working like a charm! Looks like it ultimately was an issue with the _cffi_backend.cpython-39-darwin.so file being the wrong architecture.

Thank you again everyone for your help and time.