[Tutor] code works in windows command but not ubuntu terminal

Alan Gauld alan.gauld at btinternet.com
Fri Jan 24 14:04:31 CET 2014


On 24/01/14 02:34, Tobias Quezada wrote:

>  >>>fp=open("prez.dat","r")
>  >>>x=fp.read
>  >>>(print(x)

> /IOError: [Errno 2] No such file or directory: 'prez.dat'/

Python can't see your file. You can check what python
is seeing by importing os and using listdir():

import os
os.listdir(',')  # . is the current directory

If your file is not listed then that's your problem.
Or it could be a permissions problem, but I can't
recall if that's a different error message, I suspect
so.

hth
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list