New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid pathlib.Path prepended to sys.path inside virtualenv using outside IPython #13165
Comments
I ran across another issue, as well as this one. I've posted a potential fix at #13177 (comment) that I believe should resolve both issues. |
My apologies, I should have provided that. There were a few fixes that went in, but specifically on platforms other than windows, this resolved it: The code in the master branch has been modified slightly since then, but still contains the cast to str: ipython/IPython/core/interactiveshell.py Line 949 in 1eeb3a4
There is a PR open to address the windows path at #13170 |
Software Versions Tested
Issue Description
With fresh installations of the latest Python and IPython I cannot use an IPython installed outside of a virtualenv to import modules inside that virtualenv.
I assume from the
UserWarning
that this workflow is supported on a best-effort basis, if at all. I understand if this isn't a high priority issue. That said, it is handy to not install IPython into each virtualenv I use. Historically it has worked quite well in this regard.
As far as I can determine, the cause of the issue is an unexpected
pathlib.Path
instance prepended tosys.path
.Near as I can tell from the documentation and cursory searching,
sys.path
should only containstr
instances.I don't know the IPython codebase well enough to say for sure, but from searching through issues and PRs it seems like this might have been an unanticipated result of #12548 and its 7.x backport #13146.
The issue does not seem to be reproducible in IPython 7.27.0, so that would seem to support this claim as the aforementioned backport merged a few days ago prior to the release of IPython 7.28.0.
If that is the case, maybe it would suffice to replace
ipython/IPython/core/interactiveshell.py
Line 946 in c31fed6
with something like
Steps to Reproduce
source ./venv/bin/activate
python -c 'import rich'
sys.path
Entry ComparisonsIn case it helps, here are diffs of my
sys.path
inside and outside of a virtualenv using Python and IPython.Python outside vs. inside a venv
IPython outside vs. inside a venv
The text was updated successfully, but these errors were encountered: