Search code examples
pythonpython-3.xpython-idle

IDLE uses a different python version than python3 on mac


I develop on Mac OSX (version 11.2.3) with python, using IDLE.

When I run IDLE, it uses python version 3.8.1, which has been installed in /usr/local/bin. For some reason I cannot run python3.8 via the command line from /usr/local/bin - it just returns 'file not found' or 'command not found'. I've tried running python3.8 or ./python3.8 or /usr/local/bin/python3.8 and they all come up with errors, even though I can see the file in there.

When I use python via the command line, it uses python version 3.8.2 which has been installed in usr/bin. There's python2.7 in there as well, and I can run python2.7 by typing 'python2.7' just fine. the command python runs python2.7 and the command python3 runs python 3.8.2.

Running python jobs via the crontab causes errors with scripts I have written using IDLE. These seem mainly to do with libraries. IDLE looks for libraries in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/ while python3 looks for them in /Library/Python/3.8/site-packages. When I install a package via pip3 it installs them in /Library/Python/3.8/site-packages and then I have to move them to /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/ to get them to work in IDLE.

I start IDLE as idle3 from /usr/bin and it uses python3.8.1.

How do I get IDLE to use python3.8.2 so it uses the same python as the 'python3' command?


Solution

  • In fact IDLE is no more than a Python module from the standard library. So if you have a command that starts a specific Python version (let us call it python3.x) then you can start an IDLE using that version with:

    python3.x -m idlelib