By default, Octave uses a version of python that it installs when Octave itself is installed. As of Octave 9.1.0, this version is Python 3.9.6. This installation differs from the Python instance installed by default by the OS (as of Sonoma 14.1, this is 3.12.3), or any other versions of Python you might have installed by yourself. As a result, even when you've installed the symbolic package correctly and the python prerequisite module sympy
on all your Python instances, the package might still not load correctly.
To solve this, you simply have to change the PYTHON environment variable used by Octave to determine which Python executable is called when using Python moduules. For me, my preferred version is a Python 3.11.4 instance that I installed using pyenv
. If you don't know what pyenv
is, it's basically a version manager for Python. You can install and uninstall different Python versions and activate/deactivate them globally. You can also use it to create virtual environments, but this is rather obsolte as python -m venv
is the prevailing method nowadays. I won't go into it much deeper, but I would suggest learning more about it if you're interested in using Python later for research or data science purposes. This was rather handy when setting up for Computer Seminar I also.
Anyways, to change the PYTHON environment variable, you use the command setenv PYTHON <path here>
. Replace setenv PYTHON /usr/bin/python
. Naturally, you would have to install the sympy
package for that instance, which is done by pip3 install sympy --break-system-packages
. Otherwise, you can install python with pyenv or the .pkg installers provided by the official website. In the case of pyenv, your binary should be in /Users/