python: can't open file 'timeit.py'

Discussion in 'Python' started by Aggelos I. Orfanakos, Jan 28, 2005.

  1. Hello.
    Under Gentoo Linux, I issue:

    $ python timeit.py
    python: can't open file 'timeit.py'
    $ ls -al /usr/lib/python2.3/timeit.py
    -rw-r--r-- 1 root root 9833 Oct 19 02:17 /usr/lib/python2.3/timeit.py

    But if I specify the full path, it works:

    $ python /usr/lib/python2.3/timeit.py -n 1 "pass"
    1 loops, best of 3: 3.1 usec per loop

    Any ideas how can I fix this? I think it may have to do with where
    Python looks for modules, but I am not sure.

    Thanks in advance.
     
    Aggelos I. Orfanakos, Jan 28, 2005
    #1
    1. Advertising

  2. Aggelos I. Orfanakos wrote:

    > Under Gentoo Linux, I issue:
    >
    > $ python timeit.py
    > python: can't open file 'timeit.py'
    > $ ls -al /usr/lib/python2.3/timeit.py
    > -rw-r--r-- 1 root root 9833 Oct 19 02:17 /usr/lib/python2.3/timeit.py
    >
    > But if I specify the full path, it works:
    >
    > $ python /usr/lib/python2.3/timeit.py -n 1 "pass"
    > 1 loops, best of 3: 3.1 usec per loop
    >
    > Any ideas how can I fix this? I think it may have to do with where
    > Python looks for modules, but I am not sure.


    if you pass a filename to the python interpreter, python uses that file as
    a script. it doesn't search for files.

    in Python 2.4, you can use "python -m timeit" to make it search for a
    module, and use it as a script.

    in earlier versions, create a symlink from your personal bin directory, or
    use a small shell script to run the python script.

    </F>
     
    Fredrik Lundh, Jan 28, 2005
    #2
    1. Advertising

  3. OK, the symbolic link solved the "problem". I thought that there was
    something wrong with my Python configuration; that's why I asked in the
    first place.

    Thanks.
     
    Aggelos I. Orfanakos, Jan 28, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dan Christensen
    Replies:
    4
    Views:
    569
    Peter Otten
    Jul 14, 2004
  2. Replies:
    8
    Views:
    715
    George Sakkis
    Oct 7, 2005
  3. Replies:
    0
    Views:
    348
  4. Replies:
    7
    Views:
    379
    7stud
    May 24, 2007
  5. Replies:
    3
    Views:
    2,230
    Steve Holden
    Feb 1, 2009
Loading...

Share This Page