Need help using Python in Windows Command prompt

Started by
3 comments, last by SuperVGA 11 years, 3 months ago

I'm not new to programming and understand basic structures but I'm only just now learning Python and have never really used the command line for any coding purposes except for a college class I took on C++ (Got a C I think)...*rimshot*

I downloaded "A Byte of Python" by Swaroop C H, as another forum topic suggested for starting Python, so that I'd have a reference into the language and it's syntax but I've been having some trouble during setup. I set the PATH variable correctly with ;C:\Python33 but when I go to the command line and and try to run a "hello.py" fill that I've saved I get this:

C:\Python33>python hello.py
File "hello.py", line 1
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:57:17) [MSC v.1600 64 bit
(AMD64)] on win32
^
SyntaxError: invalid syntax
Now obviously the error is invalid syntax so I went through the code but all it consists of is a simple Hello World line.
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:57:17) [MSC v.1600 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> print('Hello World')
Hello World
>>>
Now I know the book says to put python3 where I put python in the command line but whenever I put python3 I get this:
C:\Python33>python3 hello.py
'python3' is not recognized as an internal or external command,
operable program or batch file.
Anyone had the same sort of trouble when they were starting, and could maybe help me out? Thanks in advanced.
Advertisement
It's probably the encoding of hello.py ... python has many issues in this area. Try getting an editor that can convert between encoding (notepad++, sublime edit) and convert from ascii to utf-8 b...
Also, you're right about running python.exe, i don't think python3 ends up in python33/ by default...

Tried only using the command:

C:\Python33>python

to check if it will open command line interface?

Just to sure, by any chances the first line of your hello.py is:

Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:57:17) [MSC v.1600 64 bit (AMD64)] on win32

Currently working on a scene editor for ORX (http://orx-project.org), using kivy (http://kivy.org).

Yeah it is. I've started running my code in the IDLE using version 2.7 but with 3.3 whenever I run it, code OR command line, it comes up with a syntax error on the ".3" in the first line.

Is it something with version 3.3?

Yeah it is. I've started running my code in the IDLE using version 2.7 but with 3.3 whenever I run it, code OR command line, it comes up with a syntax error on the ".3" in the first line.

Is it something with version 3.3?

In response to KnolanCross; "Just to sure, by any chances the first line of your hello.py is:
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:57:17) [MSC 64 v.1600 bit (AMD64)] on win32"


Inferno, AFAIK your code isn't supposed to say


Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:57:17) [MSC v.1600 64 bit (AMD64)] on win32

Anywhere. Even on the first line. -It's incorrect syntax.
(Or correct me if I'm wrong, but I've never known a language that needs something like this, and I never wrote it myself when using Python)
What is your intent with that line?

If you write a valid statement in your hello.py file, such as


print('Hello World')

It should execute just fine.

This topic is closed to new replies.

Advertisement