January 4, 2017

Installing Python 2 and 3 together on Windows 10 with Eclipse Pydev


I already have Python 2.7 on Windows 10, and needed Python 3.x keeping 2.7.  This method works fine with Eclipse Pydev as well.  There are other ways to do have Python 2 and 3 together in Windows system, but I found this way is the simplest and easiest.

Environment:
Windows 10 64-bit. Python 2.7 64-bit, Eclipse+Pydev are already installed.

Steps:

  1. Download Python 3.x 64-bit (Windows Installer) -- same for 32-bit.
    NOTE: as of today (2017/1/4), it's better to install Python 3.5 (https://www.python.org/downloads/release/python-352/), not the latest 3.6, since TensorFlow is now available for Windows but it only installs with python 3.5, not 3.6.
  2. Install it with default setting.  Do not add it to PATH.
  3. Run Eclipse
  4. Go to Windows -> Preferences -> Pydev -> Interpreters -> Python Interpreters, then click on "Quick Auto-config"
How to use it:
  • Python 3.6 for Windows installer installs it in:
    C:\Users\<USERNAME>\AppData\Local\Programs\Python\Python36\python.exe

    My Python 2.7 is installed in:
    C:\opt\Python27\python.exe

    Since the PATH is not added, if you type "python" in console, it's Python 2.7.
  • To use Python 2 or 3:
    • Python 2: py -2 <script name>
    • Python 3: py -3 <script name>
    • Python 2 PIP: py -2 -m pip install <module>
    • Python 3 PIP: py -3 -m pip install <module>
  • Eclipse-Pydev
    1. New Pydev project
    2. Set Grammar version
    3. Set Interpreter 

RESOURCES

No comments: