Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

new.py in pwd prevents ipython from starting #630

ivanov opened this Issue Jul 29, 2011 · 3 comments


None yet
4 participants

ivanov commented Jul 29, 2011

This might not be IPython's fault, but if there's a file called new.py in the directory I launch trunk IPython from, it won't start.

17:34@new(master)$ ipython
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) 
Type "copyright", "credits" or "license" for more information.

IPython 0.11.dev -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: 
Do you really want to exit ([y]/n)? 
17:34@new(master)$ touch new.py
17:34@new(master)$ ipython
'import site' failed; use -v for traceback
Traceback (most recent call last):
  File "/home/pi/.local/bin/ipython", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 2675, in <module>
    add_activation_listener(lambda dist: dist.activate())
  File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 662, in subscribe
  File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 2675, in <lambda>
    add_activation_listener(lambda dist: dist.activate())
  File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 2180, in activate
    map(declare_namespace, self._get_metadata('namespace_packages.txt'))
  File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 1770, in declare_namespace
ImportError: No module named pyface

epatters commented Jul 29, 2011

I'm not sure which party is to blame for this particular problem, but creating a module that conflicts with a standard library module is always a bad idea. There is already a 'new' module in the standard library (at least in Python 2):



minrk commented Jul 29, 2011

This is true for all absolute-imported modules in all projects, so not specific to IPython.


fperez commented Jul 29, 2011

Yup, just like you can't do anything in the mpl directory because it includes a file named 'collections' that conflicts with the stdlib.

I'm closing this because it's an unfortunate aspect of how Python works but nothing we can control/fix/work around in IPython. I really wish Python had done something like C++, where the top-level namespace was empty and the stdlib used std as the namespace. Coupled with 'from foo:` syntax, it would be very nice:

from std:
  import sys
  import os
  import new
from numpy:
  import linalg
  import rand


But that's a rant for another place and time.

@fperez fperez closed this Jul 29, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment