[Tutor] What are the issues in running Python script on another machine (developed on Windows but will be using on Linux)

Kent Johnson kent37 at tds.net
Mon Nov 27 15:52:01 CET 2006


Python wrote:
> On Sun, 2006-11-26 at 15:14 +0000, Asrarahmed Kadri wrote:
>>  
>>  
>> Hi folks,
>>  
>> I have a couple of programs that I want to test on a different
>> machine..
>>  
>> I have developed these on Win-XP platform, but I want to test them on
>> my college's machine, which is running Linux.
>>  
>> Are there any issues involved or i just need to take my files on a USB
>> memory stick, and copy paste and that is it..?
>>  
> 
> You may need to use dos2unix to convert the DOS/Windows line endings
> 	(\r\n)
> to Unix/Linux/BSD endings
> 	(\n)
> 
> Example usage is:
> 	dos2unix myscript.py
> 
> It's a simple thing to try if you get mysterious errors.

Since Python 2.3, script files are opened with universal newline support:
http://www.python.org/doc/2.3.5/whatsnew/node7.html

It is a good idea in portable code to use os.path.join() to create file 
paths, rather than hard-coding the path separator (/ or \). Or you can 
just use / as a file separator which works on Windows and Linux.

You could conceivably have issues with text file encoding if you are 
working with text data that includes characters outside the ASCII set.

Kent



More information about the Tutor mailing list