Upgrading from Python 2 to Python 3 ↩
Among the changes introduced by RoboFont 3 is the switch from Python 2 to Python 3.
Installing Python 3 on your system
If all your coding work is done inside RoboFont 3 and DrawBot, then you don’t need to install anything else! Both apps come with Python 3 embedded.
This section is intended only for developers who also wish to use Python 3 outside of RoboFont 3.
MacOS comes with Python 2.7 out-of-the-box. If you wish to use Python 3 outside of RoboFont, you’ll need to install it on your system first.
To install Python 3, go to Python.org, click on the Downloads menu, and use the button to download the installer for the latest version of Python 3.
Once the download is finished, double-click the installer, and follow the instructions until the installation is completed.
Running Python 3 in Terminal
To run Python 3 in Terminal, use the python3
command instead of just python
:
user:~ user$ python3
Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
If your work relies on external libraries, you’ll need to install them again for Python 3. See Installing Python 3 packages (below).
While it is possible to make Python 3 the default Python, that’s probably not a good idea: it may break some applications that depend on Python 2.
For more info, see How to set Python’s default version to 3.3 on OS X?.
Running Python 3 in SublimeText
- Go to Sublime Text to: Tools → Build System → New Build System and put the next lines in the editor:
{
"cmd": ["python3", "-i", "-u", "$file"],
"file_regex": "^[ ]File \"(...?)\", line ([0-9]*)",
"selector": "source.python"
}
Then save it with a meaningful name like: python3.sublime-build
- Create a new .py file, save it on disk, and write the following code
import sys print(sys.version)
-
Go to Tools → Build system → and check python3 (or whatever name you assigned to the build system) test it with:
- Press: Cmd + B. You should read in the console something similar to
3.9.5 (default, May 4 2021, 03:36:27)
Adapted from this gist
Installing Python 3 packages
System Python
To make external packages available to the system-level Python 3, put your modules/packages or .pth
files here:
/Library/Python/3.6/site-packages/
This folder is not created automatically by the Python 3 installer. If it does not yet exist on your system, you’ll need to create it manually.
A
.pth
file can contain a series of paths to be added tosys.path
, one per line. You’ll need to create this file manually with a code editor.
RoboFont
RoboFont 3 adds /Library/Python/3.6/site-packages
to sys.path
on start-up, so all external packages installed for the system-level Python 3 will also be available in RoboFont 3.
If you wish to install external packages for RoboFont 3 only, put them in this folder instead:
/Library/Application Support/RoboFont/external_packages/
Packages installed via this folder will not be available to the system-level Python 3.
The
external_packages
folder also supports.pth
files.