set path=%path%;C:\python27 where does this code go?
please explain in detail?

Recommended Answers

All 6 Replies

Go to www.google.com and type 'set the path in windows 7' (or vista, or XP, etc). Follow the instructions of one of the first links on how to set the path in windows. Once you're at the step of editing the path, simply add ;C:\python27 to your path. Do this in an administrator account if possible.

Okay when I have set the environment variable but the following error occurs when I try running python in command prompt.

C:\Users\Shankaranarayanan>cd DESKTOP

C:\Users\Shankaranarayanan\Desktop>cd MY COMPUTER
The system cannot find the path specified.

C:\Users\Shankaranarayanan\Desktop>cd My Computer
The system cannot find the path specified.

C:\Users\Shankaranarayanan\Desktop>cd MyComputer
The system cannot find the path specified.

C:\Users\Shankaranarayanan\Desktop>cd Computer
The system cannot find the path specified.

C:\Users\Shankaranarayanan\Desktop>cd Computer\
The system cannot find the path specified.

C:\Users\Shankaranarayanan\Desktop>cd C:\

C:\>python--version
'python--version' is not recognized as an internal or external command,
operable program or batch file.

C:\>cd python32\

C:\Python32>python--version
'python--version' is not recognized as an internal or external command,
operable program or batch file.

C:\Python32>python--version\
'python--version\' is not recognized as an internal or external command,
operable program or batch file.

C:\Python32>python--version
'python--version' is not recognized as an internal or external command,
operable program or batch file.

C:\Python32>python
Python 3.2.1 (default, Jul 10 2011, 21:51:15) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> python--version
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'python' is not defined
>>> cd

I'm not sure what to do now or where the problem lies?

This is what im facing when I try to run the python interactively from the command prompt:

Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\Shankaranarayanan>cd\

C:\>python
Python 3.2.1 (default, Jul 10 2011, 21:51:15) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> print "hello"
File "<stdin>", line 1
print "hello"
^
SyntaxError: invalid syntax
>>>


is this a problem with the way environment variables are set??
IF so can someone give me the step by step method to set them as i deleted them by mistake!

This is what im facing when I try to run the python interactively from the command prompt:

Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\Shankaranarayanan>cd\

C:\>python
Python 3.2.1 (default, Jul 10 2011, 21:51:15) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> print "hello"
File "<stdin>", line 1
print "hello"
^
SyntaxError: invalid syntax
>>>


is this a problem with the way environment variables are set??
IF so can someone give me the step by step method to set them as i deleted them by mistake!

In principle, you don't need to cd to python's folder to invoke the command 'python' if C:\Python32 is in your PATH variable. Also I don't understand why in first post it was C:\Python27...

Your python statement fails because the 'print' statement became a function in python 3.0. So now, you must write

print("hello")

with parenthesis. I understand that you're a python beginner, so use a tutorial for python 3.x and not python 2.x. There are not so many differences, but 'print' is one of them. Also, please use code tags when you post code in the forum. Read this http://www.daniweb.com/software-development/python/threads/366794 and this http://www.daniweb.com/forums/announcement.php?f=8&announcementid=3

python --version not python--version
And as Gribouillis pointet out you can write python in any path(cmd) and it will work.
If environment variables(path) are ok.

You should stick with 2.7 for now,you can have both installed.
Most of stuff(tutorials/books/forum) out there is for python 2.x
The diffrence 2 to 3.
http://diveintopython3.org/porting-code-to-python-3-with-2to3.html

A few more useful guides:
http://www.swaroopch.com/notes/Python_en:Installation#For_Windows_Users
http://diveintopython.org/installing_python/windows.html
http://docs.python.org/faq/windows.html#how-do-i-run-a-python-program-under-windows

If you plan on using a Python module or package that does not support Python 3.x, make sure to stick with Python 2.7. The Django Web Framework, for example, does not (yet) support Python 3, so I stuck with Python 2.7.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.