sympy 0.7.1 作图方法

2024-06-01 01:36:00 发布

您现在位置:Python中文网/ 问答频道 /正文

我如何修复这个问题,或者找到日志来调查它?在

$ python
Python 2.7.3 (default, Dec 18 2014, 19:10:20) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from sympy import symbols
>>> from sympy.plotting import plot
OpenGL Warning: Failed to connect to host. Make sure 3D acceleration is enabled for this VM.
>>> x = symbols('x')
>>> p1 = plot(x*x)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'module' object is not callable
>>> import sympy
>>> sympy.__version__
'0.7.1.rc1'

看来绘图模块还没有完全安装?在


Tags: tofromimportdefaultforplotison
1条回答
网友
1楼 · 发布于 2024-06-01 01:36:00

this seems to be a very old version of sympy. the api has changed. in sympy 0.7.1.rc1, ^{} is a module, not a function.

我通过删除mpmathsympy的现有版本(已与apt一起安装)并安装最新版本,如下所示:

$ sudo apt-get remove  purge python-mpmath python-sympy
$ sudo python -m easy_install mpmath
$ python
Python 2.7.3 (default, Mar 14 2014, 11:57:14) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mpmath
>>> mpmath.__version__
'0.19'
$ sudo python -m easy_install sympy
$ python
Python 2.7.3 (default, Mar 14 2014, 11:57:14) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sympy
>>> sympy.__version__
'0.7.6'

现在plot()显示了该图。在

以后,请使用python -m easy_install安装最新版本,而不是{}它似乎有旧版本。在

相关问题 更多 >