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

  • Thread starter Aggelos I. Orfanakos
  • Start date
A

Aggelos I. Orfanakos

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.
 
F

Fredrik Lundh

Aggelos said:
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>
 
A

Aggelos I. Orfanakos

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top