I have installed python2.7 and python3.7.3 on same windows 10 laptop. Now I am trying to run programmes separately. On windows cmd I type
cmd>py -2 print 'hello world'
C:\Users\data\installation\python2.7\python.exe: can't open file 'print': [Errno 2] No such file or directory
I tried running on powershell
PS> python2 print 'hello world'
python2 : The term 'python2' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At line:1 char:1
+ python2 print 'hello world'
+ ~~~~~~~
+ CategoryInfo : ObjectNotFound: (python2:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException`
I try to run on powershell
> py2 print 'hello world'
py2 : The term 'py2' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included,
verify that the path is correct and try again. At line:1 char:1 + py2 print 'hello world' + ~~~ + CategoryInfo : ObjectNotFound: (py2:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException`
If I run on powershell just
> py -2 print "hello world'
I get following prompt >>>
but nothing else
same is problem with
> py -3 print ('Hello World')
C:\Users\data\installation\python\python.exe: can't open file 'print': [Errno 2] No such file or directory`
my script file (script.py
) is:
#! py -3
python --version
I read these questions:
- How do I run python 2 and 3 in windows 7?)
- How to install both Python 2.x and Python 3.x in Windows 7
I expect hello world to be printed instead of this errors are coming.