python - 属性错误 : 'module' object has no attribute 'get_altitude'

标签 python python-3.x

我的 pysolarrobot7.py 代码的这一部分抛出一个 AttributeError

def tomorrow_heading():
    increment_min = 1
    incrementeddatetime = 0
    tomorrow_corrected = 90
    if pysolar.get_altitude(maplat, maplon, datetime.datetime.utcnow()) < 0:
        while pysolar.get_altitude(maplat, maplon, (datetime.datetime.utcnow() + datetime.timedelta(minutes=incrementeddatetime))) < 0:
          incrementeddatetime = incrementeddatetime + increment_min
        sunrise_time=(datetime.datetime.utcnow() + datetime.timedelta(minutes=incrementeddatetime))
        tomorrow_heading = pysolar.GetAzimuth(maplat, maplon, sunrise_time)
        if tomorrow_heading < 0:
            if (tomorrow_heading >= -180):
                tomorrow_corrected = ((tomorrow_heading * -1) + 180)
            if (tomorrow_heading < -180):
                tomorrow_corrected = ((tomorrow_heading * -1) - 180)
        if tomorrow_heading >= 0:

以下是错误代码

root@Primerpi:/tools# python3 solarrobot7-core.py

Traceback (most recent call last):
  File "solarrobot7-core.py", line 237, in <module>
    tomorrow_static = tomorrow_heading()
  File "solarrobot7-core.py", line 176, in tomorrow_heading
    if pysolar.get_altitude(maplat, maplon, datetime.datetime.utcnow()) < 0:
AttributeError: 'module' object has no attribute 'get_altitude'

我已经用谷歌搜索了一段时间,但似乎找不到答案。 solarrobot7.py 的原始代码使用了 GetAltitudePysolar (PascalCase),我将其更改为 get_altitudepysolar (蛇形盒)。

最佳答案

pysolar 没有“get_altitude”方法: 你想要子模块“太阳能”:)

from pysolar import solar
solar.get_altitude #this will work :)

关于python - 属性错误 : 'module' object has no attribute 'get_altitude' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34582018/

相关文章:

python - 如何在 python 2.7 中使用 distutils 进行增量构建?

python - 为什么 RotatingFileHandler 附加到旧文件?

Python - 3.0 的语法是否与 3.3 相同?

python:友好数字检查

python - 取件目录 : How not to pickup files that are still being written?

python - 哪种类型提示表示属性不能为 None?

python-3.x - pandas pivot 转换 DataFrame

python - ipaddress.IPv4Network 迭代 1 个主机部分

python - 使用函数接受不是标识符的 kwargs 关键字参数是否安全?

python - for循环调用类属性报错