brandon-rhodes / pyephem

Scientific-grade astronomy routines for Python
Other
772 stars 121 forks source link

AttributeError: module 'ephem' has no attribute 'Sun' #246

Closed Nadine-Schneider closed 1 year ago

Nadine-Schneider commented 1 year ago

Hi!

I'm configuring a function in AWS Lambda that should use the prophet model. When adding a layer with all the libraries that the prophet uses, an error occurs when I try to run the code:

OpenBLAS WARNING - could not determine the L2 cache size on this system, assuming 256k
[ERROR] AttributeError: module 'ephem' has no attribute 'Sun'
Traceback (most recent call last):
 from prophet import Prophet
  File "/opt/python/lib/python3.8/site-packages/prophet/__init__.py", line 7, in <module>
    from prophet.forecaster import Prophet
  File "/opt/python/lib/python3.8/site-packages/prophet/forecaster.py", line 18, in <module>
    from prophet.make_holidays import get_holiday_names, make_holidays_df
  File "/opt/python/lib/python3.8/site-packages/prophet/make_holidays.py", line 14, in <module>
    import prophet.hdays as hdays_part2
  File "/opt/python/lib/python3.8/site-packages/prophet/hdays.py", line 13, in <module>
    from lunarcalendar import Lunar, Converter
  File "/opt/python/lib/python3.8/site-packages/lunarcalendar/__init__.py", line 2, in <module>
    from .festival import zh_festivals
  File "/opt/python/lib/python3.8/site-packages/lunarcalendar/festival.py", line 9, in <module>
    from . import solarterm
  File "/opt/python/lib/python3.8/site-packages/lunarcalendar/solarterm.py", line 11, in <module>
    from ._calc import specified_solar_term
  File "/opt/python/lib/python3.8/site-packages/lunarcalendar/_calc.py", line 361, in <module>
    _sun = ephem.Sun()    # for computing equinoxesSTART RequestId: e7d4fb8f-5db5-482c-bdc2-468a9fee5138 Version: $LATEST
2022-11-03T19:07:32.228Z e7d4fb8f-5db5-482c-bdc2-468a9fee5138 Task timed out after 3.18 seconds

END RequestId: e7d4fb8f-5db5-482c-bdc2-468a9fee5138
REPORT RequestId: e7d4fb8f-5db5-482c-bdc2-468a9fee5138  Duration: 3182.93 ms    Billed Duration: 3000 ms    Memory Size: 128 MB Max Memory Used: 22 MB  

Note: I downloaded the libraries individually and placed them in a folder that was later zipped to be used in the Lambda function.

I'm using python version 3.8. I've done tests with Ephem versions 3.7.7.1 and 4.0.0 and 4.1.3

brandon-rhodes commented 1 year ago

I never replied because I haven't yet been able to think of what could cause Sun to be missing—unless, as just occurred to me, your project itself has a module named ephem.py which is getting loaded instead. Drat. I wish I had thought of that two weeks ago.

Nadine-Schneider commented 1 year ago

Hi! No problems!

I ended up going down another path in the project and this problem no longer occurred, although others that are unrelated to Ephem did.

Just for information, I wasn't using Ephem directly. He was a dependency of Prophet.

Thanks for getting back to me and if I run into any problems I'll get back to you.

brandon-rhodes commented 1 year ago

Thanks for your reply! I'm glad you didn't spend two weeks with a broken setup because of a module name.