Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to I get Python 2.x and 3.x to co-exist? [duplicate]

Tags:

python

I'm new to programming and thought Python would be a good language to learn. Most of the tutorials I found were 2.7 based so I started to learn using that version. I've recently found a tkinter tutorial that I'd like to try out but I'm having a problem. If I run a script it will use Python 2.7 which contains Tkinter and not tkinter.

This problem made me think, how can I get my two versions to co-exist so I can program in both 2.x and 3.x?

like image 330
akaGrim Avatar asked Jul 18 '11 18:07

akaGrim


People also ask

Can Python 2 and 3 coexist Mac?

You can have both versions installed at the same time.

Can python2 and python3 coexist Linux?

You can have them coexist because 3.2 is backwards-compatible.


2 Answers

I'm not sure I understand your question, but I'll take a shot. I'm also assuming you're on Windows.

It's simple -- just install both. They will install to different directories, create different start menu folders, etc. I'd also reccomend PyWin32 for the PythonWin editor installed in both 2.7 and 3.2,

  • http://sourceforge.net/projects/pywin32/files/pywin32/Build216/pywin32-216.1.win32-py3.2.exe/download &
  • http://sourceforge.net/projects/pywin32/files/pywin32/Build216/pywin32-216.win32-py2.7.exe/download

If you mean how do you write one script that works with either Python 2 or Python 3, look at http://docs.python.org/library/2to3.html

like image 100
agf Avatar answered Oct 17 '22 13:10

agf


wget  <python download url>
tar xfvz Python-X.Y.Z.tar.gz
cd Python-X.Y.Z
configure --prefix=/path/to/python-x.y.z
make install
like image 21
Andreas Jung Avatar answered Oct 17 '22 13:10

Andreas Jung