By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,375 Members | 1,095 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,375 IT Pros & Developers. It's quick & easy.

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

P: n/a
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.

Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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>

Jul 18 '05 #2

P: n/a
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.

Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.