2
您好我正在學習Python與Edx課程的線性代數。 (http://nbviewer.ipython.org/github/ULAFF/notebooks/tree/may-14-2014/)。「類型錯誤:不是所有在字符串格式化過程中轉換的參數」在ipython筆記本
在「02.4.2.10實踐與矩陣向量乘法」與第一個框,代碼:
import generate_problems as gp
print("What is the result of the matrix vector product below?")
p = gp.Problem()
p.new_problem()
generate_problems is a module that the professor at Edx created. However, I got an error importing sympy.
當我試圖執行上面的代碼中,我得到了以下錯誤:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-1-79d56e0988cb> in <module>()
2 print("What is the result of the matrix vector product below?")
3
----> 4 p = gp.Problem()
5
6 p.new_problem()
/Users/user/Desktop/Course/Python/ipython/notebooks-master/generate_problems.pyc in __init__(self)
14 tag = ''
15
---> 16 A = self.random_integer_matrix(m, n)
17 x = self.random_integer_matrix(n, 1)
18
/Users/user/Desktop/Course/Python/ipython/notebooks-master/generate_problems.pyc in random_integer_matrix(self, m, n)
26
27 def random_integer_matrix(self, m, n):
---> 28 A = zeros((m, n))
29
30 for i in range(m):
/Users/user/anaconda/lib/python2.7/site-packages/sympy/matrices/dense.pyc in zeros(r, c, cls)
1227 if cls is None:
1228 from .dense import Matrix as cls
-> 1229 return cls.zeros(r, c)
1230
1231
/Users/user/anaconda/lib/python2.7/site-packages/sympy/matrices/dense.pyc in zeros(cls, r, c)
511 """Return an r x c matrix of zeros, square if c is omitted."""
512 c = r if c is None else c
--> 513 r = as_int(r)
514 c = as_int(c)
515 return cls._new(r, c, [cls._sympify(0)]*r*c)
/Users/user/anaconda/lib/python2.7/site-packages/sympy/core/compatibility.pyc in as_int(n)
387 raise TypeError
388 except TypeError:
--> 389 raise ValueError('%s is not an integer' % n)
390 return result
391
TypeError: not all arguments converted during string formatting
我好像太少%s爲compatibility.py?我在Mac OSX Yosemite上使用Anaconda。有人可以幫忙嗎?
任何人都可以幫忙嗎? – pythonlearner