【问题标题】:Installing Octave Symbolic Package using SymPy (macOS) - Can't get SymPy to work使用 SymPy (macOS) 安装 Octave 符号包 - 无法让 SymPy 工作
【发布时间】:2020-08-20 04:01:49
【问题描述】:

所以,我从这里安装了 Octave 符号包:

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

在 Octave 命令窗口中我输入了:

pkg install -forge symbolic

安装后我运行了一个测试(如上面的链接所示),输入:

pkg load symbolic
syms x

但是,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

接下来,我访问了以下站点来安装 SymPy(上面说要安装 Anaconda)。

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

那么,我去以下站点下载macOS的图形安装程序(Python 2.7版本)。

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

然后我从 macOS 终端测试,看看是否使用此命令安装了 Anaconda

conda --version

返回conda 4.7.11

我也输入了

conda list

返回(在一个长列表中)。 sympy 1.4 py27_0.

因此,SymPy 似乎已安装(至少在终端上)。

接下来,我回到 Octave 的命令行并输入:

sympref diagnose

这是输出:

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 无权访问 SymPy。

知道我做错了什么吗?

【问题讨论】:

    标签: anaconda octave sympy


    【解决方案1】:

    尝试以八度音程运行这些...

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

    /usr/local/anaconda3/bin 是我所有 anaconda 位的安装位置, 包括一个版本的python。您的可能会有所不同。

    sympref diagnose 然后为我传递。

    在使用符号包之前,每次启动 'octave' 时都必须这样做,但它应该是安全的。

    【讨论】:

    • 在 Mac 上,路径是 /Users//opt/anaconda3/bin/python,但这是正确的答案。
    猜你喜欢
    • 1970-01-01
    • 2017-02-17
    • 1970-01-01
    • 2019-10-07
    • 1970-01-01
    • 2020-10-12
    • 1970-01-01
    • 2018-06-04
    • 1970-01-01
    相关资源
    最近更新 更多