Jump to content

  • Log In with Google      Sign In   
  • Create Account

Need help using Python in Windows Command prompt


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 inferno959   Members   -  Reputation: 105

Like
0Likes
Like

Posted 08 January 2013 - 11:26 AM

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.

Edited by inferno959, 08 January 2013 - 11:27 AM.


Sponsor:

#2 SuperVGA   Members   -  Reputation: 1118

Like
0Likes
Like

Posted 08 January 2013 - 12:24 PM

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

#3 KnolanCross   Members   -  Reputation: 1369

Like
0Likes
Like

Posted 09 January 2013 - 07:45 AM

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


Edited by KnolanCross, 09 January 2013 - 07:46 AM.

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


#4 inferno959   Members   -  Reputation: 105

Like
0Likes
Like

Posted 12 January 2013 - 12:46 AM

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?



#5 SuperVGA   Members   -  Reputation: 1118

Like
0Likes
Like

Posted 12 January 2013 - 08:25 AM

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.


Edited by SuperVGA, 12 January 2013 - 08:33 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS