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
Ipython fails to start in bin folder due to Pathlib changes in interactiveshell.py #13177
Comments
Seems to only affect 7.28.0 |
Does this resolve your issue? diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py
index 37b31580d..5065ba239 100644
--- a/IPython/core/interactiveshell.py
+++ b/IPython/core/interactiveshell.py
@@ -919,8 +919,8 @@ def init_virtualenv(self):
# So we just check every item in the symlink tree (generally <= 3)
paths = [p]
while p.is_symlink():
- p = Path(os.readlink(p))
- paths.append(p.resolve())
+ p = Path(os.readlink(p)).resolve()
+ paths.append(p)
# In Cygwin paths like "c:\..." and '\cygdrive\c\...' are possible
if p_venv.parts[1] == "cygdrive":
@@ -953,7 +953,7 @@ def init_virtualenv(self):
"please install IPython inside the virtualenv."
)
import site
- sys.path.insert(0, virtual_env)
+ sys.path.insert(0, str(virtual_env))
site.addsitedir(virtual_env)
#------------------------------------------------------------------------- I'm experiencing a separate issue, where inserting |
Actually that might not be the right fix for the while loop. I'm a little confused by the intent of the while loop. In the end the list would likely contain duplicates as a result, but I feel like the intent was not to have that happen. |
I guess I wasn't clear when I opened the ticket, the issue is os.readlink. So if the goal of this section is to add all of the python paths I think you want something like this, adjusting the cwd so your read in links get the correct absolute path. I made a PR #13537 |
I missed that, it can be replaced with os.readlink, I'll submit the change if no one else is |
Fix (with test/coverage) would be good, but looks we'll be pushing out a reversion in the nearer term: |
This was merged |
Ipython will enter an endless loop when starting from a bin folder in a virtualenv created from pyenv.
The cause is related to the fact that the pyenv virtual env has a relative link pointing from python to python3.9\
Folder structure
env/bin/python -> /home/nathan/.pyenv/versions/3.9.7/bin/python*
env/bin/python3.9 -> python\
.pyenv/versions/3.9.7/bin/python -> python3.9
Problem code
ipython/IPython/core/interactiveshell.py
Line 776 in 6c44d22
Outside of the bin folder it works but not correctly
Edit: Fix link
The text was updated successfully, but these errors were encountered: