Yes, use pip (or pip3) to install sympy It should install the dependencies
too. Don't use the dnf packages for what you want to do. I know it is
confusing.
I am NOT a Python or pip expert. But I've run into similar errors and have
always tracked it down to something not being installed properly. I'm not
sure which version of sympy that Octave is expecting - Python(2) or
Python3. I've been tripped up before by having the wrong version of a
package installed.
Nothing against the excellent Fedora people here, but you might get more
help on
https://www.reddit.com/r/octave/.