brandon-rhodes / pyephem

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

Cannot find reference 'Sun' in '__init__.py | __init__.py' #265

Closed mxz2023 closed 1 year ago

mxz2023 commented 1 year ago

When i use ephem.Sun(date), it show the info that Cannot find reference 'Sun' in 'init.py | init.py'

Python 3.10.13 ephem 4.1.5

brandon-rhodes commented 1 year ago

Print out the value of ephem.__file__. Maybe you are importing a file of your own that you have named ephem.py, instead of importing my module?

mxz2023 commented 1 year ago

Print out the value of ephem.__file__. Maybe you are importing a file of your own that you have named ephem.py, instead of importing my module?

i run ephem is ok. you are right, it may be the PyCharm show a wrong message。but why PyCharm did show the message that Cannot find reference 'Sun' in 'init.py | init.py' . and i can't find the method of class define in the ephem module.

brandon-rhodes commented 1 year ago

The Sun object is defined dynamically from a table inside of the C module that PyEphem compiles — here's the code if you want to take a look:

https://github.com/brandon-rhodes/pyephem/blob/master/ephem/__init__.py#L90

If you are getting an error about the Sun not being defined, you need to check ephem.__file__ to see what file is being loaded. Also, try print(dir(ephem)) and paste the results here, so we can see what symbols are defined in the file.

mxz2023 commented 1 year ago

The Sun object is defined dynamically from a table inside of the C module that PyEphem compiles — here's the code if you want to take a look:

https://github.com/brandon-rhodes/pyephem/blob/master/ephem/__init__.py#L90

If you are getting an error about the Sun not being defined, you need to check ephem.__file__ to see what file is being loaded. Also, try print(dir(ephem)) and paste the results here, so we can see what symbols are defined in the file.

thanks for your help, my problem was solved.

brandon-rhodes commented 1 year ago

Thanks for making it back to close the issue, I'm glad things are working now.