![](/img/trans.png)
[英]How do I install python2.7 packages under anaconda with python3.8 already in place?
[英]Problem with mpmath under Python 3.8, but OK under 2.7
以下小程序使用 Python 3.8 失敗,但在 2.7 下正常:
from mpmath import mpf, nsum
def z(n):
x = [mpf(1) for k in range(1,n)]
return 99
print (nsum(z, [2,2]))
代碼看起來很奇怪,因為它是從一個相當大的程序中縮減而來的。 我不能再精簡了。 這可以使用https://www.python.org/shell/ 上的交互式 shell 輕松確認
錯誤報告是:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.8/site-packages/mpmath/calculus/extrapolation.py", line 1698, in nsum
return +g()
File "/usr/lib/python3.8/site-packages/mpmath/calculus/extrapolation.py", line 1745, in <lambda>
return False, lambda: f(*([0]*len(intervals)))
File "/usr/lib/python3.8/site-packages/mpmath/calculus/extrapolation.py", line 1777, in g
s += f(*args)
File "<stdin>", line 2, in z
TypeError: 'mpf' object cannot be interpreted as an integer
我錯過了一些明顯的東西嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.