Python Forum
Very basic help needed please
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Very basic help needed please
#1
First time using Python and I bought a book called Python in Easy Steps by Mike McGrath.
I have made it onto page 16!! and 'Writing your first program',
and my first attempt at this is not working,
after creating a hello.py file it says 'to launch command prompt window, navigate to new directory and precisely enter the command python hello.py - to see the Python interpreter run your program', how do you navigate to the directory through the command prompt window? I cannot do this as it does not allow me to go to the directory through the command prompt window and when I enter in the python hello. py, the below is what I get,



C:\Users\gg>C:\Python34\MyScripts>python hello.py
'C:\Python34\MyScripts' is not recognized as an internal or external command,
operable program or batch file.


I will be very grateful if someone can give me advice on how I do this, thanks very much in advance

OWL
Reply
#2
C:\Users\gg> cd C:\Python34\MyScripts
C:\Python34\MyScripts>python hello.py

OR

C:\Users\gg>python C:\Python34\MyScripts\hello.py
Reply
#3
Set up environment Variables Path,
Like in video,but also point to script folder(pip placement),
so for e.g Python 3.4 you add ;C:\python34\;C:\python34\scripts
Restart.
Now should python and pip work from anywhere in cmd.
Test and upgrade pip.
C:\>pip -V
pip 9.0.1 from c:\python34\lib\site-packages (python 3.4)

C:\>cd python34/scripts
C:\Python34\Scripts>pip install --upgrade pip
Requirement already up-to-date: pip in c:\python34\lib\site-packages
Reply
#4
(Nov-28-2016, 04:50 PM)buran Wrote: C:\Users\gg> cd C:\Python34\MyScripts
C:\Python34\MyScripts>python hello.py

OR

C:\Users\gg>python C:\Python34\MyScripts\hello.py

This is it,

Microsoft Windows [Version 10.0.14393]
© 2016 Microsoft Corporation. All rights reserved.

C:\Users\gg>C:\MyScripts>python hello.py
'C:\MyScripts' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\gg>

(Nov-28-2016, 04:51 PM)snippsat Wrote: Set up environment Variables Path,
Like in video,but also point to script folder(pip placement),
so for e.g Python 3.4 you add ;C:\python34\;C:\python34\scripts
Restart.
Now should python and pip work from anywhere in cmd.
Test and upgrade pip.
C:\>pip -V
pip 9.0.1 from c:\python34\lib\site-packages (python 3.4)

C:\>cd python34/scripts
C:\Python34\Scripts>pip install --upgrade pip
Requirement already up-to-date: pip in c:\python34\lib\site-packages
thanks for the info snippsat, can this also be done on Windows 10?
Reply
#5
Works the same in Windows 10.
Reply
#6
(Nov-28-2016, 06:39 PM)0621_OWLgale Wrote: C:\Users\gg>C:\MyScripts>python hello.py

Obviously that's NOT what I suggested...
Reply
#7
(Nov-28-2016, 07:00 PM)snippsat Wrote: Works the same in Windows 10.

thanks snippsat, I will give it a go

(Nov-28-2016, 07:22 PM)buran Wrote:
(Nov-28-2016, 06:39 PM)0621_OWLgale Wrote: C:\Users\gg>C:\MyScripts>python hello.py

Obviously that's NOT what I suggested...
Earlier I tried both Python34\MyScripts>python hello.py , and Python34\MyScripts\python hello.py

and both came up with nothing new,

but now I have tried again with Python34\MyScripts\hello.py and it works,

thanks very much buran,

it says in my book to put the word 'python' before 'hello', is that not right?

Also can I please ask you another newbie question, what is the difference between opening up a command prompt window and going through the Start list and clicking Python 3.4 (command line)?

Both are similar, but the command prompt window always has C:\Users\gg> before you can type anything in and the Python 3.4 (command line) has >>>

Many thanks for your time
Reply
#8
If you're in the command prompt and just type "python", without a filename, that's what you'll get. It's called the interpreter, or REPL (read eval print loop). It's used mainly for testing short pieces of code, otherwise you should use files and run them.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Absolutely new to python - basic advise needed mariolucas75 2 2,020 Jun-12-2020, 08:36 PM
Last Post: Yoriz
  Basic Help Needed JohnV 2 2,363 Jan-09-2019, 09:43 PM
Last Post: buran
  Very basic programming help needed: pig latin program bstocks 2 7,941 Dec-02-2017, 08:12 AM
Last Post: RickyWilson

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020