Skip to content
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 8.1.0 claims to be compatible with Python 3.8, but isn't #13554

Closed
arekfu opened this issue Feb 25, 2022 · 15 comments
Closed

IPython 8.1.0 claims to be compatible with Python 3.8, but isn't #13554

arekfu opened this issue Feb 25, 2022 · 15 comments
Milestone

Comments

@arekfu
Copy link

arekfu commented Feb 25, 2022

Steps to reproduce:

$ python --version
Python 3.8.10
$ pip install ipython
$ ipython
Traceback (most recent call last):
  File "/path/to/venv/bin/ipython", line 8, in <module>
    sys.exit(start_ipython())
  File "/path/to/venv/lib/python3.8/site-packages/IPython/__init__.py", line 123, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "/path/to/venv/lib/python3.8/site-packages/traitlets/config/application.py", line 845, in launch_instance
    app.initialize(argv)
  File "/path/to/venv/lib/python3.8/site-packages/traitlets/config/application.py", line 88, in inner
    return method(app, *args, **kwargs)
  File "/path/to/venv/lib/python3.8/site-packages/IPython/terminal/ipapp.py", line 279, in initialize
    self.init_shell()
  File "/path/to/venv/lib/python3.8/site-packages/IPython/terminal/ipapp.py", line 293, in init_shell
    self.shell = self.interactive_shell_class.instance(parent=self,
  File "/path/to/venv/lib/python3.8/site-packages/traitlets/config/configurable.py", line 540, in instance
    inst = cls(*args, **kwargs)
  File "/path/to/venv/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py", line 619, in __init__
    super(TerminalInteractiveShell, self).__init__(*args, **kwargs)
  File "/path/to/venv/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 529, in __init__
    self.init_virtualenv()
  File "/path/to/venv/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 788, in init_virtualenv
    new_path = p.readlink()
AttributeError: 'PosixPath' object has no attribute 'readlink'

If you suspect this is an IPython 8.1.0 bug, please report it at:
    https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@python.org

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    c.Application.verbose_crash=True

PosixPath.readlink() was introduced in Python 3.9.

Thank you for looking into this.

@arekfu
Copy link
Author

arekfu commented Feb 25, 2022

$ python -c "import IPython; print(IPython.sys_info())"
{'commit_hash': 'bd470fe8c',
 'commit_source': 'installation',
 'default_encoding': 'utf-8',
 'ipython_path': '/path/to/venv/lib/python3.8/site-packages/IPython',
 'ipython_version': '8.1.0',
 'os_name': 'posix',
 'platform': 'Linux-5.4.0-81-generic-x86_64-with-glibc2.29',
 'sys_executable': '/path/to/venv/bin/python',
 'sys_platform': 'linux',
 'sys_version': '3.8.10 (default, Nov 26 2021, 20:14:08) \n[GCC 9.3.0]'}

@Mec-iS
Copy link

Mec-iS commented Feb 25, 2022

same problem here:

{'commit_hash': 'bd470fe8c',
 'commit_source': 'installation',
 'default_encoding': 'utf-8',
 'ipython_path': '.venv/lib/python3.8/site-packages/IPython',
 'ipython_version': '8.1.0',
 'os_name': 'posix',
 'platform': 'Linux-5.13.0-30-generic-x86_64-with-glibc2.29',
 'sys_executable': '/home/lorenzo/code/.venv/bin/python',
 'sys_platform': 'linux',
 'sys_version': '3.8.10 (default, Nov 26 2021, 20:14:08) \n[GCC 9.3.0]'}

@olliemath
Copy link

olliemath commented Feb 25, 2022

Same same - guessing this is the offending line:

new_path = p.readlink()

You might be able to fix this by using os.readlink .. which happens to be how pathlib implements this function anyway
https://github.com/python/cpython/blob/main/Lib/pathlib.py#L1073

@olliemath
Copy link

olliemath commented Feb 25, 2022

Can confirm

sed -i 's/p.readlink()/p._from_parts(os.readlink(p,))/g' IPython/core/interactiveshell.py

within my local venv fixed this for me

@adamdoupe
Copy link

I can also confirm this bug on Ubuntu 20.04.

You can reproduce by installing ipython in a venv (which is how I triggered it).

@cnobile2012
Copy link

I'm also getting this bug on ubuntu 20.04 on Python 3.8.10.
I also get the exact tracback.

@barlaensdoonn
Copy link

Can confirm

sed -i 's/p.readlink()/p._from_parts(os.readlink(p,))/g' IPython/core/interactiveshell.py

within my local venv fixed this for me

worked for me in venv on Ubuntu 20.04, python 3.8.10. thx @olliemath!!

for reference for anyone stuck here:
the above command needs to know where to find the IPython package directory, which should be in the site-packages directory for the venv in which it was installed.

to find this path, i ran this from within the activated venv (found in this very helpful SO post):

python3 -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])

this output the absolute path to the venv's python site-packages dir, where IPython lives. I updated @olliemath 's command with the full path, and that fixed the issue:

sed -i 's/p.readlink()/p._from_parts(os.readlink(p,))/g' ~/gitbucket/infinityGAN/gainf/lib/python3.8/site-packages/IPython/core/interactiveshell.py

mayeut added a commit to mayeut/numpy that referenced this issue Feb 27, 2022
ipython 8.1.0 causes the documentation build to fail because it uses features from python 3.9

Explicitly disallow pip to install this version.

fixes numpygh-21126

xref ipython/ipython#13554
@MrMino MrMino added this to the 8.1.1 milestone Feb 27, 2022
@MrMino
Copy link
Member

MrMino commented Feb 27, 2022

From what I can see, this has been fixed in #13557. @Carreau already merged a What's-New for 8.1.1, so it should get released soon.

@deepansh96
Copy link

For MacOS users, sed -i command might not work for you. reason

What I did is I manually went to this path (note - I'm using a venv).
venv/lib/python3.8/site-packages/IPython/core/interactiveshell.py

And I changed the line p.readlink() to p._from_parts(os.readlink(p,)) and everything started working

@IVEWOR
Copy link

IVEWOR commented Feb 28, 2022

For MacOS users, sed -i command might not work for you. reason

What I did is I manually went to this path (note - I'm using a venv). venv/lib/python3.8/site-packages/IPython/core/interactiveshell.py

And I changed the line p.readlink() to p._from_parts(os.readlink(p,)) and everything started working

Working in linux as well.

@jotathebest
Copy link

sed -i 's/p.readlink()/p._from_parts(os.readlink(p,))/g' ~/gitbucket/infinityGAN/gainf/lib/python3.8/site-packages/IPython/core/interactiveshell.py

this worked for me, thanks!

@Carreau
Copy link
Member

Carreau commented Feb 28, 2022 via email

@dgealow
Copy link

dgealow commented Feb 28, 2022

For anyone who wants a workaround for the next few days but doesn't want to muck around with source files and/or doesn't care about whatever other features/fixes 8.1 added, you can just downgrade to the previous version: pip install ipython==8.0.1

@tiffanyb
Copy link

tiffanyb commented Mar 1, 2022

confirmed bug if one creates a virtual environment and pip install ipython. ipython still works fine.

charris pushed a commit to charris/numpy that referenced this issue Mar 2, 2022
ipython 8.1.0 causes the documentation build to fail because it uses features from python 3.9

Explicitly disallow pip to install this version.

fixes numpygh-21126

xref ipython/ipython#13554
@Carreau Carreau closed this as completed Mar 3, 2022
iharsuvorau added a commit to AutomatedProcessImprovement/Simod that referenced this issue Mar 3, 2022
- structure_optimizer.py is fixed
- requirements.txt file is updated to include the upgraded version of ipython which caused a crash in JetBrains IDE: https://youtrack.jetbrains.com/issue/PY-53261, ipython/ipython#13554
- new test for structure_optimizer.py is added but commented out, because it's a very slow test which is already included into test_cli.py, but still can be useful for future debugging
- docker file updated
@SonyaEick
Copy link

For MacOS users, sed -i command might not work for you. reason

What I did is I manually went to this path (note - I'm using a venv). venv/lib/python3.8/site-packages/IPython/core/interactiveshell.py

And I changed the line p.readlink() to p._from_parts(os.readlink(p,)) and everything started working

This was the one for me! Thank you for sharing!

melissawm pushed a commit to melissawm/numpy that referenced this issue Apr 12, 2022
ipython 8.1.0 causes the documentation build to fail because it uses features from python 3.9

Explicitly disallow pip to install this version.

fixes numpygh-21126

xref ipython/ipython#13554
seberg pushed a commit to seberg/numpy that referenced this issue Apr 24, 2022
ipython 8.1.0 causes the documentation build to fail because it uses features from python 3.9

Explicitly disallow pip to install this version.

fixes numpygh-21126

xref ipython/ipython#13554
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests