Python 属性错误:';模块';对象没有属性';获取高度';

Python 属性错误:';模块';对象没有属性';获取高度';,python,python-3.x,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_a

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:
def明天的标题():
增量_min=1
incrementeddatetime=0
明天_=90
如果pysolar.get_高度(maplat、maplon、datetime.datetime.utcnow())小于0:
而pysolar.get_高度(maplat,maplon,(datetime.datetime.utcnow()+datetime.timedelta(分钟=递增的datetime))<0:
incrementeddatetime=incrementeddatetime+增量\u min
日出时间=(datetime.datetime.utcnow()+datetime.timedelta(分钟=递增的datetime))
明天的航向=pysolar.getAzimition(maplat、maplon、日出时间)
如果标题<0:
如果(明天标题>=-180):
明天修正=((明天标题*-1)+180)
如果(标题<-180):
明天修正=((明天标题*-1)-180)
如果明天标题>=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'
root@Primerpi:/tools#python3 solarrobot7-core.py
回溯(最近一次呼叫最后一次):
文件“solarrobot7 core.py”,第237行,在
明天\静态=明天\标题()
文件“solarrobot7 core.py”,第176行,在明天的标题中
如果pysolar.get_高度(maplat、maplon、datetime.datetime.utcnow())小于0:
AttributeError:“模块”对象没有“获取高度”属性
我在谷歌上搜索了一段时间,似乎找不到答案。solarrobot7.py的原始代码使用了
GetAltitude
Pysolar
(PascalCase),我将其更改为
get\u altitude
Pysolar
(snake\u案例)。

Pysolar没有“get\u altitude”方法: 您需要子模块“太阳能”:


它似乎在说pysolar在它的定义中没有一个函数叫做get_aighty。看看网上的其他一些代码示例,我想问一下你们是如何导入pysolar的。谢谢,伙计们。在第一次调用之前,我会尝试将建议的行写入代码中,并在某个地方进行实验,直到我做对为止。哇。谢谢各位。这似乎已经做到了。当然,我会遇到另一个新的错误,但我会查看“solar”中的GetAzimition是否也改变了语法。真的很感激-我不是程序员。
from pysolar import solar
solar.get_altitude #this will work :)