Forgive the top-posting, but when in Rome...

Running 'chcp' at the command line will show the default code page. Judging from the OP's name it is probably an Arabic version of Windows.

Since Python 2.6 works it probably is falling back to something besides cp720. Try:
  import sys
  print sys.stdout.encoding
to find out what.

Python 3.0 probably has a bug if it runs but doesn't work correctly as described by the OP below.

Python 3.1 "refuses to guess" and displays an error. Since Python 3.X uses Unicode for strings it really needs to know the encoding of the terminal to decode stdin and encode to stdout. Implementing a cp720 codec would likely fix the problem.

-Mark



"ALAN GAULD" <alan.ga...@btinternet.com> wrote in message news:339296.66934...@web86707.mail.ird.yahoo.com...
Forwarding to the tutor list with cut n paste sessions.

It looks to me like the code page issue somebody else
referred to is the problem but the behaviour seems a
bit extreme, I'd have thought it might have chosen
a default value or something...

But I'm not sure what causes it to select cp720 in
the first place. Where does Py_Initialize get its values?
Are they set in the environment somewhere?

And why is 2.6 OK? I know 3.0 did some changes around
locale handling but I can't recall what they were.
I assume this is a side effect of those changes?
Alan Gauld
Author of the Learn To Program website
http://www.alan-g.me.uk/




----- Forwarded Message ----
From: Khalid Al-Ghamdi <emailkg...@gmail.com>
To: ALAN GAULD <alan.ga...@btinternet.com>
Sent: Sunday, 15 November, 2009 18:02:25
Subject: Re: [Tutor] getting python 3 to run from the command line (version 2)


Hi,
I'm really sorry for this hassle!

Python31 (gives error):

C:\Users\KE>python
Fatal Python error: Py_Initialize: can't initialize sys standard streams
LookupError: unknown encoding: cp720

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

C:\Users\KE>cd c:\python31

c:\Python31>python
Fatal Python error: Py_Initialize: can't initialize sys standard streams
LookupError: unknown encoding: cp720

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

Python30 (doesn't respond):

c:\Python31>cd c:\python30

c:\Python30>python
Python 3.0.1 (r301:69561, Feb 13 2009, 20:04:18) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
2+2


Python26(works ok):

C:\Users\KE>cd c:\python26

c:\Python26>python
Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
2+2
4


Thanks very much













On Sun, Nov 15, 2009 at 8:16 PM, ALAN GAULD <alan.ga...@btinternet.com> wrote:

Unfortunately the image didn't get to me.


To copy/paste from a cmd window click the small icon
at the left hand end of the title bar.


From that select Edit->Mark
Use the mouse to select the text you want to copy
Use the menu again to do Edit->Copy


Now paste into your mail program.


You can make this easier by opening the properties
dialog from the same menu, and on the Options tag
tick QuickEdit. This will allow you to select with
the mouse and copy by hitting return after selecting.


This is very useful when sending python examples
to the
tutor list! :-)



Alan Gauld
Author of the Learn To Program website

http://www.alan-g.me.uk/






________________________________
From: Khalid Al-Ghamdi <emailkg...@gmail.com>
To: Alan Gauld <alan.ga...@btinternet.com>
Sent: Sunday, 15 November, 2009 7:11:06
Subject: Re: [Tutor] getting python 3 to run from the command line (version 2)



Hi Alan,


this is how the problem looks from
my work pc (which is xp. at home i use vista). and yes i don't know how copy and paste from the cmd so here is an image:







As you can see when I try to access python31 it gives me the error above. When I use python 26 it works fine. Now, I don't have python30 installed at my work PC, but what happens is when I enter c:\python30\python it initiates and gives me a blank prompt(>>>) then when i enter something (2+2 for example) it returns (>>>) as if i just pressed enter without entering any code. It just doesn't process the code for me.


I hope you can be of help.


thanks


On Sat, Nov 14, 2009 at 9:56 PM, Alan Gauld <alan.ga...@btinternet.com> wrote:


"Khalid Al-Ghamdi" <emailkg...@gmail.com> wrote



when i try to code something it just gives me a new line without any
processing of the code. (for example:2+2 returns a new line)


You mean you get to the >>> prompt?
And you type 2+2 you get this:






2+2







With just a newline between your input and the next >>> prompt?


when I tried to change the path to the directory that contains python 31 and

enter *python (c:\python31>)*,

I'm not surprised it doesn't work, that should have python trying to start
executing a folder. But....


*fatal python error: Py_Initialize: can't initialize sys standard streams

I get a very different message:

C:\Documents and Settings\Alan Gauld>python (C:\Python31)
python: can't open file '(C:\Python31)': [Errno 22] Invalid argument



When i change the directory to c:\python26 and then enter it works ok.
so can anyone tell me why this is happening?


Nope, sorry, I don't understand how the 2.6 version works if
you are passing in a folder as you did for 3.1

Do you know how to cut n paste from a cmd window>
It would probably help if you pasted in the actuall sessions
into your mail.

HTH,


--
Alan Gauld

Author of the Learn to Program web site
http://www.alan-g.me.uk/


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor





--------------------------------------------------------------------------------


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor



_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to