Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '-*-': 0.07; 'python3': 0.07; 'utf-8': 0.07; 'encode': 0.09; 'encoding:': 0.09; 'runs': 0.10; 'python': 0.11; 'windows': 0.15; '(ubuntu': 0.16; 'codec': 0.16; 'encoding.': 0.16; 'from:name:vincent vande vyvre': 0.16; 'ordinal': 0.16; 'received:195.130': 0.16; 'received:telenet- ops.be': 0.16; 'subject:run': 0.16; 'subject:windows': 0.16; 'utf8': 0.16; '\xe9crit': 0.16; 'header:User-Agent:1': 0.23; 'skip:" 40': 0.26; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; 'character': 0.29; 'os,': 0.31; 'file': 0.32; 'run': 0.32; 'linux': 0.33; '(most': 0.33; 'skip:# 10': 0.33; 'comment': 0.34; 'could': 0.34; "can't": 0.35; 'really': 0.36; 'should': 0.36; 'to:addr:python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; '8bit%:6': 0.40; 'skip:u 10': 0.60; 'simple': 0.61; 'email addr:gmail.com': 0.63; 'charset:windows-1252': 0.65; 'header :Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71 Date: Thu, 14 Aug 2014 16:46:23 +0200 From: Vincent Vande Vyvre User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Unable to run =?windows-1252?Q?print=28=27R=E9ussi=27=29_o?= =?windows-1252?Q?n_windows_and_on_linux?= References: <4dd67a80-b466-4866-ab67-d9a94c0b7ddf@googlegroups.com> <53ecba3e$0$1989$426a74cc@news.free.fr> In-Reply-To: <53ecba3e$0$1989$426a74cc@news.free.fr> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: vincent.vandevyvre@oqapy.eu List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1408027618 news.xs4all.nl 2976 [2001:888:2000:d::a6]:57983 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:76311 Le 14/08/2014 15:31, YBM a écrit : > Le 14/08/2014 14:35, marc.vanhoomissen@gmail.com a écrit : >> Hello, >> >> This very simple program runs well on windows 7 >> >> # -*- utf8 -*- >> print('Réussi') >> >> But, when I start the vrey same file on Linux (ubuntu 14), I got: >> >> Traceback (most recent call last): >> File "/partages/bureau/PB/Dev/Python3/test.py", line 2, in >> print('R\xe9ussi') >> UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' in >> position 1: ordinal not in range(128) >> >> What should i do to let the same program run on both OS, without >> changes? > > the correct comment line should be : # -*- encoding: utf-8 -*- > and it could be usefull to begin with #!/usr/bin/env python > or #!/usr/bin/env python3 : > > $ cat > réussi.py > #!/usr/bin/env python > # -*- encoding: utf-8 -*- > print('Réussi'); > ^D > $ chmod +x réussi.py > $ ./réussi.py > Réussi > $ python réussi.py > Réussi > > Nothing to do with the file encoding. ... if the OP use really Python 3