rye icon indicating copy to clipboard operation
rye copied to clipboard

ModuleNotFoundError: No module named 'setuptools'

Open anna-hope opened this issue 1 year ago • 7 comments

Steps to Reproduce

  1. Have an existing project with a setup.py file
  2. Run rye init

The setup.py is extremely simple:

from setuptools import setup

# See setup.cfg file

if __name__ == "__main__":
    setup()

I know the docs say "Note that Rye today does not support setup.py based projects," but also I found this issue, which suggests rye init should work in some capacity.

I guess rye init --no-import could be a workaround, but that would complicate the project setup.

I also uninstalled and re-installed Rye to make sure it wasn't some issue with my installation.

Expected Result

The project can be initialized successfully.

Actual Result

error: failed to proxy setup.py
Traceback (most recent call last):
  File "/Users/annahope/<project>/./setup.py", line 2, in <module>
    from setuptools import setup
  File "/var/folders/b6/nm_w0grs5vx0_xq0tpsvft6h0000gn/T/.tmpmXonDM/setuptools.py", line 12, in <module>
    import setuptools as __setuptools
  File "/var/folders/b6/nm_w0grs5vx0_xq0tpsvft6h0000gn/T/.tmpmXonDM/setuptools.py", line 12, in <module>
    import setuptools as __setuptools
ModuleNotFoundError: No module named 'setuptools'

Version Info

rye 0.23.0 commit: 0.23.0 (0fdcdda6c 2024-02-13) platform: macos (aarch64) self-python: [email protected] symlink support: true

Stacktrace

No response

anna-hope avatar Feb 14 '24 20:02 anna-hope

The import doesn't really work today for setupl.py based projects, at least not well enough. You probably can make some progress by running rye init --build-system=setuptools.

mitsuhiko avatar Feb 14 '24 22:02 mitsuhiko

@mitsuhiko rye init --build-system=setuptools has the same issue. But, thank you for clarifying that the import doesn't work at the moment. I'll try to proceed with rye init --no-import.

anna-hope avatar Feb 14 '24 22:02 anna-hope

I ran into this same issue and was able to use pip to install setuptools into the rye virtual environment located at ~/.rye/self (at least for me with a default installation).

cd ~/.rye/self
./bin/pip install setuptools

Not ideal to be manually installing packages into the rye-managed virtual environment, but it did work.

willfrey avatar Feb 27 '24 02:02 willfrey

The same as me. And with some research, it seems that it's because setuptools is not been installed when create a venv by default since python 3.12. So is that worth to execute pip install setuptools automaticlly when we use python3.12

what's new in python 3.12 Remove bundled setuptools

WinChua avatar Mar 19 '24 03:03 WinChua

This also happens with python 3.10.

Edit: It seems rye uses 3.12 internally to run rye init, even if the config.toml contains

[default]
toolchain = "3.10"

sbor23 avatar Mar 28 '24 11:03 sbor23