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

ImportError: No module named 'backports' with Python 3.4 #9416

Closed
zanpeeters opened this issue Apr 22, 2016 · 3 comments
Closed

ImportError: No module named 'backports' with Python 3.4 #9416

zanpeeters opened this issue Apr 22, 2016 · 3 comments
Milestone

Comments

@zanpeeters
Copy link

Just upgraded IPython to 4.2.0 on Python 3.4 and starting from the terminal fails:

> ipython
Traceback (most recent call last):
  File "/opt/local/bin/ipython", line 4, in <module>
    from IPython import start_ipython
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/IPython/__init__.py", line 48, in <module>
    from .core.application import Application
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/IPython/core/application.py", line 24, in <module>
    from IPython.core import release, crashhandler
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/IPython/core/crashhandler.py", line 28, in <module>
    from IPython.core import ultratb
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/IPython/core/ultratb.py", line 121, in <module>
    from IPython.utils.terminal import get_terminal_size
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/IPython/utils/terminal.py", line 27, in <module>
    import backports.shutil_get_terminal_size
ImportError: No module named 'backports'

IPython/utils/terminal.py tries to import backports.shutil_get_terminal_size which is missing. I am using Python 3.4 and backports is not needed, shutil can be used directly.

If I replace "backports.shutil_get_terminal_size" with "shutil" on lines 9 and 125 in terminal.py, everything works fine for me. This should be wrapped in a "if PY2" or added to py3compat.py.

Other relevant information:

OS: Mac OS X 10.6.8
Python version: 3.4.4
IPython version: 4.2.0
Installer: MacPorts

I install IPython through MacPorts (port install py34-ipython). In the Portfile, backports-shutil_get_terminal_size is added as a dependency, but only for Python 2.7, which is appropriate.

@minrk
Copy link
Member

minrk commented Apr 22, 2016

This is a macports bug: it has failed to express a dependency on backports.shutil_get_terminal_size, which is a dependency of IPython 4.2 on all versions of Python as it is now. We can consider updating this dependency for Python 3, where the backport really only serves as an import shim.

@minrk
Copy link
Member

minrk commented Apr 22, 2016

#9417 updates the backport dependency to only apply on Python 2, and use shutil directly on Python 3. But the ports package for 4.2 is incorrect in specifying that the backports package is a dependency only on Python 2.

@minrk minrk added this to the 4.2.1 milestone Apr 25, 2016
@minrk minrk closed this as completed Apr 25, 2016
@minrk
Copy link
Member

minrk commented Apr 25, 2016

closed by #9417

nikolas added a commit to ccnmtl/dmt that referenced this issue May 3, 2016
marbre added a commit to marbre/gentoo that referenced this issue Jun 6, 2016
@Carreau Carreau modified the milestones: 4.2.1, 5.2 Aug 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants