How to have python 2 and 3 both on windows?

Sunil KR krlinus at yahoo.com
Sun Apr 24 03:29:55 EDT 2022


The question is not one of conversion. The question is this:
When I have both python 2 and python3, why is my python 2 script breaking? And when I remove python3 the problem goes away?


In both cases (regardless of installing python 3 or not) I am using only python 2 to run the python2 script. Why does the installation of python3 affect the python2, and how can I get them to work without stepping on one another?



 

    On Saturday, April 23, 2022, 09:59:46 PM PDT, Dennis Lee Bieber <wlfraed at ix.netcom.com> wrote:  
 
 On Sun, 24 Apr 2022 01:19:38 +0000 (UTC), Sunil KR <krlinus at yahoo.com>
declaimed the following:

>
>-- Why are my strings being sent to python3, so that I get the unicode related error?
>-- in other cases I see error pertaining to the print function

    In python2, the default for strings is BYTES -- you must explicitly ask
for unicode (for literals, using u'literal' notation). Python3 strings are,
by default, interpreted as unicode (with the encoding for source code [and
hence, literals] specified somewhere via a special comment). Getting a
normal python2 string requires using the b'literal' notation to indicate
/bytes/.

    Also, in Python2, print is a language statement, not a function. If you
have any print statements that do not have ( ) surrounding the output
items, it WILL fail in Python3.

>In my case, I don't own the python2 scripts and so I am not allowed to change any part of them. And I wouldn't need to either, if I can make python 2 and 3 coexist on my system
>

    Even if you are not "allowed to change" those scripts, have you tried
feeding them through the 2to3 conversion script just to see what type of
changes would be required?
https://docs.python.org/3/library/2to3.html


-- 
    Wulfraed                Dennis Lee Bieber        AF6VN
    wlfraed at ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/
-- 
https://mail.python.org/mailman/listinfo/python-list
  


More information about the Python-list mailing list