ipython bug with file token.py in path

Bug #115062 reported by Guilherme Gondim (semente)
2
Affects Status Importance Assigned to Milestone
ipython (Ubuntu)
Won't Fix
Medium
Unassigned

Bug Description

Binary package hint: ipython

See:

. . . . . . . . .

tmp$ touch token.py
tmp$ ipython
Traceback (most recent call last):
  File "/usr/bin/ipython", line 26, in <module>
    import IPython
  File "/usr/lib/python2.5/site-packages/IPython/__init__.py", line 60, in <module>
    __import__(name,glob,loc,[])
  File "/usr/lib/python2.5/site-packages/IPython/genutils.py", line 36, in <module>
    from IPython.Itpl import Itpl,itpl,printpl
  File "/usr/lib/python2.5/site-packages/IPython/Itpl.py", line 82, in <module>
    from tokenize import tokenprog
  File "/usr/lib/python2.5/tokenize.py", line 38, in <module>
    COMMENT = N_TOKENS
NameError: name 'N_TOKENS' is not defined
tmp$ rm token.{py,pyc}
tmp$ ipython
Python 2.5.1 (r251:54863, May 2 2007, 16:56:35)
Type "copyright", "credits" or "license" for more information.

IPython 0.7.3 -- An enhanced Interactive Python.
? -> Introduction to IPython's features.
%magic -> Information about IPython's 'magic' % functions.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.

In [1]:

. . . . . . . . .

Revision history for this message
Scott Kitterman (kitterman) wrote :

I am not able to replicate this problem as described. Would you please see if you can replicate it now and provide a more complet step by step process.

Changed in ipython:
status: Unconfirmed → Needs Info
Revision history for this message
Scott Kitterman (kitterman) wrote :

The version of Python you are running is not the one provided by any current Ubuntu release. What Python are you running?

Revision history for this message
Guilherme Gondim (semente) (semente) wrote :

$ apt-cache policy ipython python-minimal
ipython:
  Installed: 0.7.3-1
  Candidate: 0.7.3-1
  Version table:
 *** 0.7.3-1 0
        500 http://archive.ubuntu.com feisty/universe Packages
        100 /var/lib/dpkg/status
python-minimal:
  Installed: 2.5.1-0ubuntu3
  Candidate: 2.5.1-0ubuntu3
  Version table:
 *** 2.5.1-0ubuntu3 0
        500 http://archive.ubuntu.com feisty-proposed/main Packages
        100 /var/lib/dpkg/status
     2.5.1~rc1-0ubuntu3 0
        500 http://archive.ubuntu.com feisty/main Packages

But in Debian Etch with python2.4 occurs the same problem. The problem is with ipython!

Step by step:

1. install packages ipython
2. run ipython (works fine)
3. create token.py file in a directory in PYTHONPATH
4. run ipython (error!)

. . . . . . . . .

$ sudo aptitude install ipython [ok]
$ ipython [ok]
$ touch token.py [ok]
$ ipython [NameError: name 'N_TOKENS' is not defined]
$ rm token.{py,pyc}
$ ipython [ok]

Thanks!

Revision history for this message
Scott Kitterman (kitterman) wrote :

Where are you putting the token.py file that you made? I'm still unable to replicate this when I put it in /usr/local/lib/python2.5/site-packages (which is in the PYTHONPATH).

BTW, I did upgrade to the unreleased Python you are running too in an attempt to replicate it. Still no luck.

What architecture are you running?

Revision history for this message
Guilherme Gondim (semente) (semente) wrote :

Hmm

The token.py must be first than /usr/lib/python2.5/token.py.

Try:

$ PYTHONPATH=/usr/local/lib/python2.5/site-packages:$PYTHONPATH ipython

or put him in the same dir that you run ipython!

Thanks!

Revision history for this message
Scott Kitterman (kitterman) wrote :

/usr/lib/python2.5/token.py did it. Confirmed.

Changed in ipython:
importance: Undecided → Medium
status: Needs Info → Confirmed
Revision history for this message
Dennis Kaarsemaker (dennis) wrote :

Creating a module with the same name as a built-in one will give you problems of you put it as first in your $PATH. This should not be considered a bug as this is expected python behaviour.

Changed in ipython:
status: Confirmed → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.