[AstroPy] Can't import astropy subpackages
Evert Rol
evert.rol at gmail.com
Wed Jan 31 23:40:37 EST 2018
Travis, you probably just need an extra
import astropy.constants
line.
Looks like the constants subpackage isn't automatically imported (anymore) when astropy is imported.
I think this is largely the default for most Python packages (os.path an exception to the rule): subpackages don't get imported automatically.
> Hello everyone,
>
> I’m not really a new astropy user, but for some reason I have this problem with astropy after I installed via conda. I tried uninstalling and installing again, but no luck. Below are the steps I took to get this error.
>
> 1) open ipython in terminal
> 2) import astropy
> 3) print (astropy.constants.c)
>
> I get the following error: module ‘astropy’ has no attribute ‘constants’
>
> Which is very odd because it’s always worked for me before in my previous installations.
>
> When I type astropy. in ipython, it only lists the following options when hitting tab: conf, config, cython_version, extern, find_api_page(), log, logger, online_docs_root, online_help(), test(), tests, utils, version.
>
> And what’s more odd, is when I type:
> from astropy.constants import c
>
> It works just fine… I’m running Python 3.6.4, ipython 6.2.1, conda 4.4.8, and astropy 2.0.3 on macOS High Sierra. Any insight why this is happening? Thank you all.
>
> Best Regards,
>
> Travis Thieme
> Graduate Student
> Institute of Astronomy
> National Tsing Hua University
>
> _______________________________________________
> AstroPy mailing list
> AstroPy at python.org
> https://mail.python.org/mailman/listinfo/astropy
More information about the AstroPy
mailing list