0

Sympyをimportしinit_session() 又は init_printing()を用いるとそれ以後のセルが[*]となってしまいどれだけ待っても実行されません。
Jupyter notebookを使用しても同様の問題が生じます。

init_session()以降が動かない

コンソール上のIpython上ではinit_session()を行っても正常に動作します。

コマンドラインでの挙動

Python 3.8.5 (default, Sep  3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.19.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from sympy import *

In [2]: init_session()
IPython console for SymPy 1.6.2 (Python 3.8.5-64-bit) (ground types: python)

These commands were executed:
>>> from __future__ import division
>>> from sympy import *
>>> x, y, z, t = symbols('x y z t')
>>> k, m, n = symbols('k m n', integer=True)
>>> f, g, h = symbols('f g h', cls=Function)
>>> init_printing()

Documentation can be found at https://docs.sympy.org/1.6.2/


In [3]: fx = sin(x)*cos(x)**3

In [4]: fx
Out[4]:
          3
sin(x)⋅cos (x)

init_session()をコメントアウトすると正常に動作します。

画像の説明をここに入力

anacondaを2度再インストールしましたが同様の問題に悩まされています。

環境:
Windows10 -64bit
anaconda 4.9.2
Python 3.8.5.final.0
sympy 1.6.2
Jupyter lab 2.2.6
notebook 6.1.4

5
  • windows10、python3.8.6、sympy1.6.2で再現しました。ですが、「init_session()」は必要ですか?
    – merino
    2020年12月4日 0:26
  • sympyの版数か、sympyjupyter関連あるいはpythonとの版数問題かもしれませんね。AnacondaではないPython 3.8.6環境のsympy 1.7,jupyterlab 2.2.9,notebook 6.1.5では正常に動作しています。
    – kunif
    2020年12月4日 1:07
  • init_session()はinit_printing()やx, yなどの変数のシンボライズを自動的にやってくれるため必要です。 特に行列を表示する際にきれいになるので愛用しています。
    – Yuz
    2020年12月4日 1:20
  • 私の場合、「init_printing()」なら問題なく動作しました。jupyter labは2.2.9です。 ※pythonはanacondaではありません。
    – merino
    2020年12月4日 2:16
  • Anacondaの2020.11版をインストールしてConsoleで全モジュールをconda update conda および conda update --allすればsympyも1.7に上がって質問のソースでも正常に動作するようです。
    – kunif
    2020年12月4日 6:48

0

この質問に回答するには、ログインする必要があります。

のタグが付いた他の質問を参照する。