1

I use python2.7 mostly, but I wanted to use python3.3 for a specific task. I referred to the existing questions Python 3x and python 2.x The solution suggested there did not work for me. I have couple of questions based on the issues I have been facing.

  1. Adding python3.3 to the path variable.Some post(add python27_path) suggested to copy the file and rename it. I tried renaming C:\Python3.3\python.exe to C:\Python3.3\python3.exe. But this did not work for me.

  2. Adding libraries to PYTHONPATH: Had added C:\Python33\Lib\site-packages to the PYTHONPATH. When I ran the code with Python3.3, it was using libraries of python2.7. Is it possible for the libraries to coexist on the same machine and if I call python2.7 it should look only for its modules?

4
  • 1
    Install Cygwin and run python3 and python2 like you would on *nix Commented Jul 26, 2013 at 4:49
  • What did not work in the first case? Couldn't rename, or will it run the wrong Python, or...? Commented Jul 26, 2013 at 4:50
  • @JoachimIsaksson I added the it to the path. But when i called python3 in my command prompt. It could still not find. was a bit surprising to me. Commented Jul 26, 2013 at 4:57
  • @karthikbharadwaj Did you update the path and start a new command window? Existing windows don't get the path update, only newly launched ones. Commented Jul 26, 2013 at 5:05

4 Answers 4

1

Those lovely people over at python have come up with the perfect solution for you as a part of python 3.3 - a launcher for windows that works all this out for you take a look about half way down this page.

The other option is to have a switcher script which changes your path and pythonpath variables for you.

Sign up to request clarification or add additional context in comments.

Comments

0

Well, you can explicitly specify which version of python to use by making sure that you add the appropriate python location to the beginning of the path before you invoke the python command. Something like this.

Let's assume that you PATH variable in Windows is : c:\windows\system32;c:\python27\;...

Execute your python scripts using 3.3 this way :

SET PATH = "c:\python33\";%PATH%
python yourscript.py

Execute your python scripts using 2.7 this way :

SET PATH = "c:\python27\";%PATH%
python yourscript.py

This is a good way to execute scripts without having to install too many third party software products. A simple BAT file can then solve your requirement.

Comments

0

The variant

 SET PATH = "c:\python27\";%PATH%

is invalid. You should use

 SET PATH=C:\python33\;%PATH%

Comments

0

On windows, if you already added both versions of python to the PATH, you can use:

py -2.7

or

py -3.6

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.