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

Fredrik Lundh fredrik at pythonware.com
Fri Jan 28 16:09:02 CET 2005


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> 






More information about the Python-list mailing list