Closed jamesbraza closed 2 months ago
Do you maybe have the complete steps to reproduce here? (From rye init, rye add etc or complete pyproject.toml). Is IPython installed in the current rye project or not?
If ipython is installed into the local rye project, the default way to run it is rye run ipython
python -m IPython
will also work (using rye's python shim).
Yeah here is a full repro:
> rye init project
> cd project
> rye lock
> source .venv/bin/activate
> pip install ipython
> ipython
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'IPython'
I realized the issue is that rye
-made .venv
's don't seem to work with pip
:
> which python
/Users/user/code/project/.venv/bin/python
> which pip
pip: aliased to noglob pip3
> which pip3
/Users/user/.pyenv/shims/pip3
Do you know why pip
is not properly aliased to the .venv
when it's activated?
They don't include a user-exposed pip at all. It's part of Rye's philosophy: https://rye.astral.sh/philosophy/.
Oh I see, sorry for the false report here. Good to know and appreciate the response!
Great that it was solved. Ipython has a feature where it can interface with venvs it's not installed in, so for some typical use cases I would suggest doing that (however, it needs to be the same python version between the ipython install and the venv).
Thanks @bluss , appreciate the follow up. Actually if you have a second, I am curious about this:
Ipython has a feature where it can interface with venvs it's not installed in
I just set up something like:
pyenv global 3.12.4
, with ipython
installedrye
local with Python 3.12.4, no ipython
installed/added, rye
's .venv
activatedDo you know how to trigger that IPython feature such that it falls back onto what's installed in system Python?
The recipe is like this
Activate the venv that has the libraries you want to import (the 2).
Run ipython using the python where it's installed. That's /path/to/ipython/environment/bin/ipython (/path/to/ipython/environment/bin/python -m IPython
should also be an alternative)
Ah I follow and thank you. So in my case then what I'd do is:
source .venv/bin/activate
/Users/user/.pyenv/shims/python -m IPython
Case closed, cheers!
Steps to Reproduce
It seems IPython doesn't work with a
.venv
made byrye sync
:Expected Result
IPython to work in a Rye
.venv
Actual Result
Version Info
rye 0.36.0 commit: 0.36.0 (2024-07-07) platform: macos (aarch64) self-python: cpython@3.12.3 symlink support: true uv enabled: true
Stacktrace
No response