[Tutor] getting python 3 to run from the command line (version 2)

Mark Tolonen metolone+gmane at gmail.com
Sat Nov 14 20:25:53 CET 2009


"Khalid Al-Ghamdi" <emailkgnow at gmail.com> wrote in message 
news:dfac564f0911140854v42fa4e0ehe5868517a50ef8bb at mail.gmail.com...
> hi all,
>
> I realize my question was previous question was phrased, well, vaguely, as 
> I
> learn from your responses so here's version 2 of my question:
>
> i'm running windows vista and have python 30 ,31 and 26 installed.!
>
> when I try to run python form the command line by printing *python *to
> whichever path i have there (in my case:C:\users\KE>) it runs python 30, 
> but
> 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)
>
> when I tried to change the path to the directory that contains python 31 
> and
> enter *python (c:\python31>)*,  it just crashes and gives me the following
> message:
>
>
> *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 teh application's support team for more Information.*
> *
> *
> When i change the directory to c:\python26 and then enter it works ok.
>
> so can anyone tell me why this is happening?
>
> PS: I learn from Alan Gauld's response that windows defaults to python30
> when i enter python because in the system variables python30 was entered
> first and I confirmed that that was true, but still python 30 doesn't
> process my code and python 31 crashes.

My version of Python and Windows doesn't understand cp720.  According to 
http://en.wikipedia.org/wiki/Code_page_720, it is a OEM Arabic code page. 
The Windows-equivalent is 'cp1256'.  I have Python 2.6 and it doesn't have a 
codec for cp720, but does for cp1256.

Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] 
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> u'abc'.encode('cp720')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
LookupError: unknown encoding: cp720
>>> u'abc'.encode('cp1256')
'abc'

If you are running on an Arabic version of Windows, you might change the 
console code page to 1256 and see if that works.  Run 'chcp 1256' before 
running 'python'.

-Mark




More information about the Tutor mailing list