randy3k/radian

Radian 0.6.9 fails to run on python 3.12.1

alex-gable opened this issue · 6 comments

Environment

It looks like this is coming from a package dependency rchitect.

I know environments/versions can be finicky, but I tried to make this as clear-cut as possible (at least in my set up)

I use pyenv (to manage python versions) as well as pipx (to manage python CLI tools). So, in my .zshrc I first set PIPX_DEFAULT_PYTHON = "$HOME/.pyenv/shims/python". I then source ~/.zshrc to ensure my terminal environment is up-to-date.

Reproducing

From there I run pyenv global 3.12. after this, python --version returns 3.12.1. After this I install radian with pipx and attempt to run radian

radian installed with 3.12

> pipx install radian
installed package radian 0.6.9, installed using Python 3.12.1
These apps are now globally available
  - radian
done! ✨ 🌟 ✨
> radian
Traceback (most recent call last):
  File "/Users/gable/.local/bin/radian", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/gable/.local/pipx/venvs/radian/lib/python3.12/site-packages/radian/app.py", line 11, in main
    from rchitect.utils import Rhome, rversion
  File "/Users/gable/.local/pipx/venvs/radian/lib/python3.12/site-packages/rchitect/__init__.py", line 1, in <module>
    from .setup import init, loop
  File "/Users/gable/.local/pipx/venvs/radian/lib/python3.12/site-packages/rchitect/setup.py", line 7, in <module>
    from .utils import Rhome, ensure_path, system2utf8
  File "/Users/gable/.local/pipx/venvs/radian/lib/python3.12/site-packages/rchitect/utils.py", line 11, in <module>
    from pkg_resources import parse_version
ModuleNotFoundError: No module named 'pkg_resources'

clearing the installed version of radian

then we need to make sure we clear the currently installed version of radian. to uninstall:

> pipx uninstall radian
uninstalled radian! ✨ 🌟 ✨

radian installed with 3.11

then we need to tell pyenv to use version 3.11 as the default:

pyenv global 3.11

I then exit the terminal and open a clean, new session. In that new terminal, I install radian again and confirm it was built with 3.11

> pipx install radian
installed package radian 0.6.9, installed using Python 3.11.7
These apps are now globally available
  - radian
done! ✨ 🌟 ✨

This log confirms radian was built with python version 3.11(.7). I then run radian.

> radian
R version 4.2.2 (2022-10-31) -- "Innocent and Trusting"
Platform: aarch64-apple-darwin20 (64-bit)

r$>

radian is now running as expected. please let me know if I can provide additional, clarifying information to help reproduce!

Hi Alex, thanks for your issue (and your workaround! ), I get a very similar error under windows 10 and python 12.1.
ModuleNotFoundError: No module named 'pkg_resources'

Some log messages below.

workaround for windows 10

  • deinstall radian for python 312 (follow alex's example above)
  • install Python 3.11 :)
  • install radian again, for python 3.11
  • add path_to_R_directory into windows PATH environment variable . In my system, i added D:\desktop\R\R-4.2.2\bin\x64 (Adapt as necessary).
  • Make sure no variable named R_HOME is declared within those Windows environment variables: I had an Exception: Cannot load shared library: because of it.
  • success !

log messages under python 3.12

C:\Users\elm>pip install -U radian
Collecting radian
  Using cached radian-0.6.9-py3-none-any.whl
Collecting rchitect<0.5.0,>=0.4.3 (from radian)
  Using cached rchitect-0.4.4.tar.gz (32 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Collecting prompt-toolkit<3.1,>=3.0.41 (from radian)
  Obtaining dependency information for prompt-toolkit<3.1,>=3.0.41 from https://files.pythonhosted.org/packages/ee/fd/ca7bf3869e7caa7a037e23078539467b433a4e01eebd93f77180ab927766/prompt_toolkit-3.0.43-py3-none-any.whl.metadata
  Using cached prompt_toolkit-3.0.43-py3-none-any.whl.metadata (6.5 kB)
Collecting pygments>=2.5.0 (from radian)
  Obtaining dependency information for pygments>=2.5.0 from https://files.pythonhosted.org/packages/97/9c/372fef8377a6e340b1704768d20daaded98bf13282b5327beb2e2fe2c7ef/pygments-2.17.2-py3-none-any.whl.metadata
  Using cached pygments-2.17.2-py3-none-any.whl.metadata (2.6 kB)
Collecting wcwidth (from prompt-toolkit<3.1,>=3.0.41->radian)
  Obtaining dependency information for wcwidth from https://files.pythonhosted.org/packages/fd/84/fd2ba7aafacbad3c4201d395674fc6348826569da3c0937e75505ead3528/wcwidth-0.2.13-py2.py3-none-any.whl.metadata
  Using cached wcwidth-0.2.13-py2.py3-none-any.whl.metadata (14 kB)
Collecting cffi>=1.10.0 (from rchitect<0.5.0,>=0.4.3->radian)
  Obtaining dependency information for cffi>=1.10.0 from https://files.pythonhosted.org/packages/e9/63/e285470a4880a4f36edabe4810057bd4b562c6ddcc165eacf9c3c7210b40/cffi-1.16.0-cp312-cp312-win_amd64.whl.metadata
  Using cached cffi-1.16.0-cp312-cp312-win_amd64.whl.metadata (1.5 kB)
Collecting six>=1.9.0 (from rchitect<0.5.0,>=0.4.3->radian)
  Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting pycparser (from cffi>=1.10.0->rchitect<0.5.0,>=0.4.3->radian)
  Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB)
Using cached prompt_toolkit-3.0.43-py3-none-any.whl (386 kB)
Using cached pygments-2.17.2-py3-none-any.whl (1.2 MB)
Using cached cffi-1.16.0-cp312-cp312-win_amd64.whl (181 kB)
Using cached wcwidth-0.2.13-py2.py3-none-any.whl (34 kB)
Building wheels for collected packages: rchitect
  Building wheel for rchitect (pyproject.toml) ... done
  Created wheel for rchitect: filename=rchitect-0.4.4-cp312-cp312-win_amd64.whl size=63329 sha256=ead405ab6701d91bea5a6b3242ab3fb6d13c4f9b72ae98ab333a1e3dbdec7f56
  Stored in directory: c:\users\elm\appdata\local\pip\cache\wheels\69\e8\4b\aac5fc867ffc47a1f25355e17ba24eec4fd291dd4cf385f64b
Successfully built rchitect
Installing collected packages: wcwidth, six, pygments, pycparser, prompt-toolkit, cffi, rchitect, radian
Successfully installed cffi-1.16.0 prompt-toolkit-3.0.43 pycparser-2.21 pygments-2.17.2 radian-0.6.9 rchitect-0.4.4 six-1.16.0 wcwidth-0.2.13

[notice] A new release of pip is available: 23.2.1 -> 23.3.2
[notice] To update, run: python.exe -m pip install --upgrade pip

C:\Users\elm>D:\desktop\Python312\Scripts\radian.exe
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "D:\desktop\Python312\Scripts\radian.exe\__main__.py", line 7, in <module>
  File "D:\desktop\Python312\Lib\site-packages\radian\app.py", line 11, in main
    from rchitect.utils import Rhome, rversion
  File "D:\desktop\Python312\Lib\site-packages\rchitect\__init__.py", line 1, in <module>
    from .setup import init, loop
  File "D:\desktop\Python312\Lib\site-packages\rchitect\setup.py", line 7, in <module>
    from .utils import Rhome, ensure_path, system2utf8
  File "D:\desktop\Python312\Lib\site-packages\rchitect\utils.py", line 11, in <module>
    from pkg_resources import parse_version
ModuleNotFoundError: No module named 'pkg_resources'

Please upgrade rchitect to v0.4.4.

Please upgrade rchitect to v0.4.4.

I have rchitect 0.4.4, same error

Please specify in the README that python must be < 3.12

Oh, python 3.12 no longer ships with pkg_resources by default. Please install it manually.

@randy3k should it be added as a dependency then so it installs by default?

Okay so, checking the notes for the changes that removed pkg_resources from python 3.12 it appears for those using pipx like myself the command that needs to now be run (until setuptools is added as a dependency) is:

pipx install radian --preinstall setuptools

for other users installing radian into a venv they recommend running pip install setuptools ahead of installing an application like radian.