Python IDLE: Change Python Version

I have Python 2.x and 3.x on my machine (Mac OS X 10.6).
For some things I want to use ver 2, but for others I want ver 3. I like the IDLE software for editing/running, but it always uses version 3.

Is there any way to change the version of the interpreter that IDLE uses?

Thanks!

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

There are different versions of IDLE installed for each Python version. Depending on how you installed Python on Mac OS X, you may find different folders in /Applications. Look for a Python 3.n (n = 1 or 2) folder with an IDLE in it. Or, from a terminal command line, you may find an idle2.6 and an idle3 or idle3.1 or idle3.2.

Method 2

Usually each Python version installs its own version of IDLE. I don’t know how this works on Mac, but for Windows it works like this:

python2.7 C:Program FilesPython27Libidlelibidle.pyw

starts the Python 2 IDLE and

python3.2 C:Program FilesPython32Libidlelibidle.pyw

starts the Python 3 IDLE.

Method 3

In the Windows environment, if you want to use particular install of IDLE, I find the easiest way is to right click on the .py file and choose “open with”. Then navigate to the IDLE.bat file in the Python version install location you want to use. I find picking just the ilde.py doesn’t work but the .bat file does.

E. g.

D:Python27ArcGISx6410.4Libidlelibidle.bat

or

D:Python27DesktopArcGIS10.4Libidlelibidle.bat

Method 4

If there are 2 or more Python versions installed on you computer but you can only open one Python IDLE (suppose IDLE using Python 2.7) and if you dont have IDLE for Python 3.5 installed on your computer (check the folder /usr/bin for idle or idle-python2.7 And if idle-python3.5 is not there then its not currently installed). Then you just have to install idle-python3.5 by executing following command through CLI.

sudo apt install idle-python3.5

Or you can just install it by Software Manager in Linux.
Search for IDLE and select your preferred IDLE to install.

Method 5

In RHEL 7 after installing yum install python-tools
typing “idle3.6” worked for me.

Method 6

I use Sublime 3 as my editor on mac. Several backend files required changes. Changes were made to Python3.sublime-build file:

{
"cmd": ["/usr/local/bin/python3", "-u", "$file"],
"file_regex": "^[ ]*File "(...*?)", line ([0-9]*)",
"selector": "source.python",
"encoding": "utf8",
"path": "/usr/local/Frameworks/Python.framework/Versions/3.3/bin/"
}

The SublimeREPL package was also installed.

The Main.sublime-menu file was edited to reflect the following:

{"command": "repl_open",
 "caption": "Python3 - RUN current file",
 "id": "repl_python_run",
  "mnemonic": "d",
  "args": {
        "type": "subprocess",
        "encoding": "utf8",
        "cmd": ["python3", "-u", "$file_basename"],
        "cwd": "$file_path",
        "syntax": "Packages/Python/Python.tmLanguage",
        "external_id": "python",
        "extend_env": {"PYTHONIOENCODING": "utf-8"}
        }
}

These are the major changes in a nutshell. More details with guided step-by-step instructions are available at
Setting Up Sublime Text 3 for Python3 Development.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x