python: can't open file ''

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

Aggelos I. Orfanakos wrote:

> Under Gentoo Linux, I issue:
> $ python
> python: can't open file ''
> $ ls -al /usr/lib/python2.3/
> -rw-r--r--  1 root root 9833 Oct 19 02:17 /usr/lib/python2.3/
> But if I specify the full path, it works:
> $ python /usr/lib/python2.3/ -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.


More information about the Python-list mailing list