Re: Verifying I installed Python correctly

2022-04-25 Thread Sunil KR via Python-list
cd C:\google-python-exercises> python hello.py


this doesn't looks like a valid command. However, is it because a newline got 
swallowed by misformatting?

For clarity, I am reproducing the correct version of the steps:

cd /d  C:\google-python-exercises
python hello.py
The error is:  The system cannot find the path specified. If the above version 
of the steps is what you actually performed, I think that by "path" it may be 
referring to the python command. For the system to be able to find python, its 
location should be updated in the "PATH" environment variable. 

If you would rather not distract yourself with modifying the PATH variable you 
can do what Barry says and just use py, because py is installed in a location 
already specified in PATH

If you want to fix your PATH environment variable there is more than one way to 
do this and you may find this out by googling, as you may get a better 
illustrated answer than it would be possible on this forum

Sunil


 

On Monday, April 25, 2022, 10:50:52 AM PDT, Greg  wrote: 
 
 
 I am trying to get Hello World to appear under my directory. The files of

*C:\Users\gd752>cd C:\google-python-exercises> python hello.py*
*The system cannot find the path specified.*

*C:\Users\gd752>cd C:\google-python-exercises>*
*The syntax of the command is incorrect.*

I installed version 3.10. I am stuck and could use some help.
Thx,


[image: directory pic.png]
-- 
https://mail.python.org/mailman/listinfo/python-list
  
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to have python 2 and 3 both on windows?

2022-04-24 Thread Sunil KR via Python-list
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 
 wrote:  
 
 On Sun, 24 Apr 2022 01:19:38 + (UTC), Sunil KR 
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
    wlfr...@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/
-- 
https://mail.python.org/mailman/listinfo/python-list
  
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to have python 2 and 3 both on windows?

2022-04-23 Thread Sunil KR via Python-list
I am happy with how the python starts up. When I use
python
I get python 2. 
I am ok with using py -3 for my new scripts, even using the shebang like
#!py -3
I don't want to put a unix (or for that matter windows) path in the shebang, as 
it is not platform portable
But the real question/s for me is/are

-- 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 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


   > On 22 Apr 2022, at 17:10, Sunil KR via Python-list 
 wrote:
> 
> I have some scripts that are old and won't work under python2 and at the 
> same time I am writing new scripts which will use python3. However, if python 
> 2 and 3 cannot co-exist in a windows box it will be impossible to transition
> What I try:- remove all pythons and launchers- Use windows installer and 
> install python2 in python27 directory- Use windows installer and install 
> python3 in python310 directory- When installing python3 I opt in to install 
> the launcher- Test with py -2 and py -3 and see that I get the expected 
> prompt- just typing python gets me python2

As you have proved you can install many versions of python at the same time on 
windows.

In your scripts set the shebang to run the python version you want.
E.g
#!/usr/bin/python2
Or
#!/usr/bin/python3

The python launcher py.exe will then do the right thing after looking at en 
shebang line.

Also you can edit the INI file of the py.exe launcher to set the defaults the 
way you want them. Do a search for “py.exe ini” to file the path to the file, I 
do not have it my finger tips.

Tip “py.exe -0” will list the state of installed pythons.

Barry

> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

  
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to have python 2 and 3 both on windows?

2022-04-22 Thread Sunil KR via Python-list
Please excuse the formatting in my previous message. And it is not complete 
even, so here is the rest of it.
What happens after I follow the above steps:
- Upon running one of my python 2 scripts (using python2), I see this error:
    """       ^SyntaxError: (unicode error) 'unicodeescape' codec can't decode 
bytes in position 237-238: truncated \u escape
I tried for a bit, but I could not isolate the content of the file that may be 
causing this problem. But any idea about this problem would be greatly 
appreciated.
Removing python3 solves this issue..
Sunil
 

On Friday, April 22, 2022, 09:09:22 AM PDT, Sunil KR via Python-list 
 wrote:  
 
 I have some scripts that are old and won't work under python2 and at the same 
time I am writing new scripts which will use python3. However, if python 2 and 
3 cannot co-exist in a windows box it will be impossible to transition
What I try:- remove all pythons and launchers- Use windows installer and 
install python2 in python27 directory- Use windows installer and install 
python3 in python310 directory- When installing python3 I opt in to install the 
launcher- Test with py -2 and py -3 and see that I get the expected prompt- 
just typing python gets me python2
-- 
https://mail.python.org/mailman/listinfo/python-list
  
-- 
https://mail.python.org/mailman/listinfo/python-list


How to have python 2 and 3 both on windows?

2022-04-22 Thread Sunil KR via Python-list
I have some scripts that are old and won't work under python2 and at the same 
time I am writing new scripts which will use python3. However, if python 2 and 
3 cannot co-exist in a windows box it will be impossible to transition
What I try:- remove all pythons and launchers- Use windows installer and 
install python2 in python27 directory- Use windows installer and install 
python3 in python310 directory- When installing python3 I opt in to install the 
launcher- Test with py -2 and py -3 and see that I get the expected prompt- 
just typing python gets me python2
-- 
https://mail.python.org/mailman/listinfo/python-list