Khalid Al-Ghamdi wrote:
Hi,

for some reason I haven't been able to get python 3 to work from the the
command line. I've added it to the the path in the the system variables but
still no luck. when I try to run python 2.6 it works flawlessly, though,
bearing in mind that it wasn't added to the system variables!

i'm running windows vista and have python 30 ,31 and 26 installed.

all of this , by the way, was just to get easy install to work so i can get
nose working to do some practice of unit testing!

can anyone shed some light on the issue?

thanks

We need more details to really diagnose the problem, although you've given enough for us to guess. If you really want to help us help you, explain what you mean by "haven't been able to get..." Just what do you try, and what happens when you try it? What does your PATH look like, and where is the python installation you're trying to run.

I'll make some guesses anyway. You've got Vista, and you're running from a command prompt. When you try the following:
  c:\programming\sources\project\ >  python myscript.py

the system runs Python 2.6 on your script (which is in the project directory). Now you want it to run Python 3.1 instead. I have no clue what you've tried.

There are four variables I know of which help determine whether you can run a python script in various ways, and using various installations of python. Two of these are in the registry, and two are in the environment (environment variables). Keywords are assoc, ftype, PATHEXT, and PATH

I'll start with the environment variable PATH. This determines how the system interprets word "python" on the command above. If you have multiple python.exe files, you can choose between them in two different ways: you can change the PATH, or you can change what you type. My preference is as follows:

Make a batch directory (Mine is called m:\t\bat ) and use it to put all your batch files for various purposes. Add that directory to your PATH to point there (by using Control panel, so it will still work on reboots). Close any existing command lines (DOS boxes), because they won't have the new PATH value. Start a new one, and check PATH to make sure it's there, and spelled right.

For each installation of python.exe, create a pythonNN.bat which knows how to run that particular version. So I might have a python26.bat which has the following two lines in it:

   Echo  Running Python version 2.6
   c:\python26\python.exe %*

When everything's working, you can take out the Echo line, and add a '@' symbol in front of the other line.


The other three things I mentioned only affect you if you're trying to run a python script "directly", without typing "python" in front of its name.


One other thing: It's useful to have a simple script called version.py, which looks something like:

  import sys
  print (sys.version)

(but don't indent the lines, naturally. For that matter, don't indent them in the bat files above either.)

HTH,
DaveA

_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to