1

So, I've installed the Octave Symbolic Package from here:

https://sourceforge.net/p/octave/symbolic/ci/master/tree/

In the Octave command window I typed:

pkg install -forge symbolic

After the install I ran a test (as shown in link above) by typing:

pkg load symbolic
syms x

However, I got an following error with syms x.

Symbolic pkg v2.8.0: Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named sympy
error: Python cannot import SymPy: have you installed SymPy?
    Try "sympref diagnose" for more information.
error: called from
    assert_have_python_and_sympy at line 123 column 7
    python_ipc_popen2 at line 79 column 5
    python_ipc_driver at line 59 column 13
    python_cmd at line 163 column 9
    valid_sym_assumptions at line 38 column 10
    assumptions at line 82 column 7
    syms at line 97 column 13

Next, I visited the following site to install SymPy (which says to install Anaconda).

https://docs.sympy.org/latest/install.html#anaconda

So, then I go to the following site and download the graphical installer for macOS (Python 2.7 version).

https://www.anaconda.com/distribution/#download-section

Then I tested from the macOS terminal to see if Anaconda is installed using this command

conda --version

which returns conda 4.7.11.

I also typed

conda list

which returns (among a long list). sympy 1.4 py27_0.

So, it appears that SymPy is installed (at least at the terminal).

Next, I go back to the command line of Octave and typed:

sympref diagnose

Here is the output:

Symbolic package diagnostics
============================

Python and SymPy are needed for most features of the Symbolic package.

The Python interpreter is currently: "python".

Computers may have more than one Python interpreter installed.  If you
need to, you can select a different one using the PYTHON environment
variable (see "help sympref").  For example, to use Python 3, try
    setenv PYTHON python3
    sympref reset

Attempting to run python -c "print(\"Python says hello\")"

status = 0
output = Python says hello

Good, Python ran correctly.


Python version
--------------

Let's check what version of Python we are calling...

Attempting to run python -c "import sys; print(sys.version)"

status = 0
output = 2.7.15 (default, Feb  5 2019, 12:31:36)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]


SymPy Python Library
--------------------

SymPy is a Python library used by Symbolic for almost all features.

Attempting to run python -c "import sympy; print(sympy.__version__)"

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named sympy
status =  1
output =

Unfortunately status was non-zero: probably Python cannot import sympy.

  * Is there an error message above?

  * Do you have SymPy installed?  If not, please try to install it and
    try again.

  * If you do have SymPy installed, maybe it's installed for a different
    Python interpreter than the one we found?  Please try "setenv" as
    described above to change your python interpreter.

Octave doesn't have access to SymPy.

Any idea what I did wrong?

1 Answer 1

2

Try running these in octave...

setenv PYTHON /usr/local/anaconda3/bin/python
pkg load symbolic

/usr/local/anaconda3/bin was where all my anaconda bits were installed, including a version of python. Yours may differ.

sympref diagnose then passes for me.

You will have to do this every time you start 'octave' before using the symbolic package, but it should be safe.

1
  • On a Mac the path would be /Users/<username>/opt/anaconda3/bin/python, but this is the right answer. Commented May 24, 2021 at 11:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.