I'm using Octave on OS X and I wanted to use the symbolic package.
I had to install the package running pkg install -forge symbolic
on Octave, but then I also had to install sympy
. I installed both mpmath
and sympy
running on my terminal two commands: pip install sympy
and pip install mpmath
.
At this point I tried to use the package launching this small script
pkg load symbolic
syms t
but it gave me this error
Symbolic pkg v2.9.0: Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: 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 62 column 15
pycall_sympy__ at line 163 column 11
valid_sym_assumptions at line 38 column 10
assumptions at line 82 column 7
syms at line 97 column 13
Then I run the command sympref diagnose
as suggested, whit this output
Symbolic package diagnostics
============================
Python and SymPy are needed for most features of the Symbolic package.
The Python interpreter is currently: "python3".
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 2, try
setenv PYTHON python2
sympref reset
Attempting to run python3 -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 python3 -c "import sys; print(sys.version)"
status = 0
output = 3.9.4 (default, Apr 14 2021, 21:04:05)
[Clang 11.0.0 (clang-1100.0.33.17)]
SymPy Python Library
--------------------
SymPy is a Python library used by Symbolic for almost all features.
Attempting to run python3 -c "import sympy; print(sympy.__version__)"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: 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.
Python3 is the right interpreter, but the version is not. If i run the very same code import sys; print(sys.version)
I don't get the output Octave provides me
output = 3.9.4 (default, Apr 14 2021, 21:04:05)
[Clang 11.0.0 (clang-1100.0.33.17)]
but I get
3.10.4 (v3.10.4:9d38120e33, Mar 23 2022, 17:29:05) [Clang 13.0.0 (clang-1300.0.29.30)]
May this be the problem?
I also tried to:
- uninstall and install again both sympy and mpmath
- install both of them using pip3 rather than pip
- move mpmath and sympy in the same folder, which is
/Users/jacopo/Library/Python/3.10/lib/python/site-packages
- downgrade sympy package with the command
pip install --user sympy==1.5.1
- checked if both of them are installed running
pip show <pkg_name>
, and they are - restart Octave, Python and the Terminal multiple times
Output of which -a python python3 pip pip3
:
/usr/bin/python
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3
/usr/local/bin/python3
/usr/bin/python3
/Library/Frameworks/Python.framework/Versions/3.10/bin/pip
/Library/Frameworks/Python.framework/Versions/3.10/bin/pip3
/usr/local/bin/pip3
/usr/bin/pip3