jimifiki
jimifiki

Reputation: 5534

ipython giving attributeerror when launched

When I launch

ipython

I get

AttributeError: '_NamespacePath' object has no attribute 'sort'

I can do nothing. I tried to pip3 uninstall stuff but I get the same message (the stack of the error being slightly different). Waht I can do? Should I burn the computer and restart with a new one? python works fine.

Full stack:

Traceback (most recent call last):
  File "/usr/local/bin/ipython", line 7, in <module>
    from IPython import start_ipython
  File "/usr/local/lib/python3.5/dist-packages/IPython/__init__.py", line 55, in <module>
    from .terminal.embed import embed
  File "/usr/local/lib/python3.5/dist-packages/IPython/terminal/embed.py", line 16, in <module>
    from IPython.terminal.interactiveshell import TerminalInteractiveShell
  File "/usr/local/lib/python3.5/dist-packages/IPython/terminal/interactiveshell.py", line 91, in <module>
    class TerminalInteractiveShell(InteractiveShell):
  File "/usr/local/lib/python3.5/dist-packages/IPython/terminal/interactiveshell.py", line 134, in TerminalInteractiveShell
    highlighting: \n %s""" % ', '.join(get_all_styles())
  File "/usr/local/lib/python3.5/dist-packages/pygments/styles/__init__.py", line 79, in get_all_styles
    for name, _ in find_plugin_styles():
  File "/usr/local/lib/python3.5/dist-packages/pygments/plugin.py", line 62, in find_plugin_styles
    for entrypoint in iter_entry_points(STYLE_ENTRY_POINT):
  File "/usr/local/lib/python3.5/dist-packages/pygments/plugin.py", line 45, in iter_entry_points
    import pkg_resources
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2927, in <module>
    @_call_aside
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2913, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2952, in _initialize_master_working_set
    add_activation_listener(lambda dist: dist.activate())
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 956, in subscribe
    callback(dist)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2952, in <lambda>
    add_activation_listener(lambda dist: dist.activate())
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2515, in activate
    declare_namespace(pkg)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2097, in declare_namespace
    _handle_ns(packageName, path_item)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2047, in _handle_ns
    _rebuild_mod_path(path, packageName, module)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2066, in _rebuild_mod_path
    orig_path.sort(key=position_in_sys_path)
AttributeError: '_NamespacePath' object has no attribute 'sort'

Upvotes: 1

Views: 847

Answers (1)

Sylhare
Sylhare

Reputation: 7059

It could be your version of python (assuming you're on v3.x), or a missed dependencie.

Try to uninstall ipython

pip uninstall ipython

Then upgrade your pip and setuptool version (they might not be up to date causing problems):

pip install --upgrade pip
pip install --upgrade setuptools

Run the installation of ipython again either with:

  • with pip
pip install ipython
  • or easy_install:
easy_install ipython

On my side I often use Anaconda which has most dependencies and package already integrated and working. So you may try it out if the above does not work for you.

Upvotes: 2

Related Questions