[英]AttributeError: module 'math' has no attribute 'dist'
I have code that works well in local Jupiter Notebook.我的代码在本地 Jupiter Notebook 中运行良好。 I try to run the same code in google colab but there I get an AttributeError: module 'math' has no attribute 'dist'.
我尝试在 google colab 中运行相同的代码,但出现 AttributeError:模块“math”没有属性“dist”。 The code below is couple of lines from my project
下面的代码是我项目中的几行
import math
distance = math.dist(x, y)
Update: the default version of python in google colab is 3.7.13更新:google colab中python的默认版本是3.7.13
Update: I found that the problem occurs because of version of python.更新:我发现问题是由于 python 的版本引起的。 The function dist was added to math module only since Python 3.8.
仅在 Python 3.8 之后,才将 function dist 添加到数学模块。
The colab successfully updated to 3.9.13 colab成功更新到3.9.13
#install python 3.9
!sudo apt-get update -y
!sudo apt-get install python3.9
#change alternatives
!sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7
!sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9
#check python version
!python --version
#3.9.13
The code above I found on StackOverFlow here我在 StackOverFlow 上找到的上面的代码here
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.