ModuleNotFoundError: No module named 'setuptools'
Steps to Reproduce
- Have an existing project with a
setup.pyfile - 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
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 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.
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.
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
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"