运行sage
时,我可以毫无问题地导入sage.finance
。但是,在运行sage -python
(或sage -ipython
)时,导入sage.finance
会带来以下回溯:
>>> import sage.finance
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/finance/__init__.py", line 3, in <module>
import all
File "/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/finance/all.py", line 1, in <module>
from stock import Stock
File "/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/finance/stock.py", line 20, in <module>
from sage.structure.all import Sequence
File "/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/structure/all.py", line 1, in <module>
from factorization import Factorization
File "/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/structure/factorization.py", line 187, in <module>
from sage.rings.integer import Integer
File "integer.pyx", line 1, in init sage.rings.integer (sage/rings/integer.c:38248)
File "morphism.pyx", line 1, in init sage.categories.morphism (sage/categories/morphism.c:7490)
File "map.pyx", line 1, in init sage.categories.map (sage/categories/map.c:8604)
File "parent.pxd", line 12, in init sage.structure.element (sage/structure/element.c:31286)
File "map.pxd", line 4, in init sage.structure.parent (sage/structure/parent.c:24406)
AttributeError: 'module' object has no attribute 'Map'
任何想法都可能导致此错误,如何从
sage -python
导入财务模块? 最佳答案
我认为您不能直接导入内容,而不能从Sage shell中仅从sage.all
导入。鼠尾草进口很多东西。尝试这个。
$ sage -ipython
Python 2.7.5 (default, Oct 7 2013, 07:44:02)
Type "copyright", "credits" or "license" for more information.
IPython 0.13.2 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: from sage.all import finance
In [2]: finance.[tab]
finance.MarkovSwitchingMultifractal
finance.Stock
finance.TimeSeries
finance.autoregressive_fit
finance.black_scholes
finance.fractional_brownian_motion_simulation
finance.fractional_gaussian_noise_simulation
finance.lazy_import
finance.multifractal_cascade_random_walk_simulation
finance.stationary_gaussian_simulation
关于python - 无法从sage-python导入sage.finance,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24133496/