Python Astropy导入错误,“未加载父模块”

Python Astropy导入错误,“未加载父模块”,python,importerror,astropy,Python,Importerror,Astropy,我正在尝试在Windows7CPython2.7.5下运行Astropy。 我从上可用的二进制文件进行了新的安装,但当我尝试导入时,出现了一个系统错误:未加载父模块“astropy”,无法执行相对导入 但是,如果我再次尝试导入,错误将更改为与系统权限相关的已知问题ImportError 问题是我使用一个管理员帐户在系统范围内安装了所有东西。对如何进行有什么建议吗? 在这里,您可以看到完整的trackback Python 2.7.5 (default, May 15 2013, 22:44:1

我正在尝试在Windows7CPython2.7.5下运行Astropy。 我从上可用的二进制文件进行了新的安装,但当我尝试导入时,出现了一个系统错误:未加载父模块“astropy”,无法执行相对导入 但是,如果我再次尝试导入,错误将更改为与系统权限相关的已知问题ImportError

问题是我使用一个管理员帐户在系统范围内安装了所有东西。对如何进行有什么建议吗?

在这里,您可以看到完整的trackback

Python 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)] Type "copyright", "credits" or "license" for more information.

IPython 1.1.0 -- An enhanced Interactive Python. ?         -> Introduction and overview of IPython's features. %quickref -> Quick reference. help      -> Python's own help system. object?   -> Details about 'object', use 'object??' for extra details. Using matplotlib backend: TkAgg

In [1]: import astropy Custom TB Handler failed, unregistering
--------------------------------------------------------------------------- SystemError                               Traceback (most recent call last) c:\python27\lib\site-packages\astropy\logger.py in ipy_exc_handler(ipyshell, ety pe, evalue, tb, tb_offset)
    270             def ipy_exc_handler(ipyshell, etype, evalue, tb, tb_offset=N one):
    271                 # First use our excepthook
--> 272                 self._excepthook(etype, evalue, tb)
    273
    274                 # Now also do IPython's traceback

c:\python27\lib\site-packages\astropy\logger.py in _excepthook(self, etype, valu e, traceback)
    220             self.error(message, extra={'origin': mod.__name__})
    221         else:
--> 222             self.error(message)
    223         self._excepthook_orig(etype, value, traceback)
    224

C:\Python27\lib\logging\__init__.pyc in error(self, msg, *args,
**kwargs)    1173         """    1174         if self.isEnabledFor(ERROR):
-> 1175             self._log(ERROR, msg, args, **kwargs)    1176    1177     def exception(self, msg, *args, **kwargs):

C:\Python27\lib\logging\__init__.pyc in _log(self, level, msg, args, exc_info, e xtra)    1266                 exc_info = sys.exc_info()    1267         record = self.makeRecord(self.name, level, fn, lno, msg, args, e xc_info, func, extra)
-> 1268         self.handle(record)    1269    1270     def handle(self, record):

C:\Python27\lib\logging\__init__.pyc in handle(self, record)    1276   """    1277         if (not self.disabled) and self.filter(record):
-> 1278             self.callHandlers(record)    1279    1280     def addHandler(self, hdlr):

C:\Python27\lib\logging\__init__.pyc in callHandlers(self, record)    1316                 found = found + 1    1317                 if record.levelno >= hdlr.level:
-> 1318                     hdlr.handle(record)    1319             if not c.propagate:    1320                 c = None    #break out

C:\Python27\lib\logging\__init__.pyc in handle(self, record)
    747             self.acquire()
    748             try:
--> 749                 self.emit(record)
    750             finally:
    751                 self.release()

c:\python27\lib\site-packages\astropy\logger.py in
_stream_formatter(self, recor d)
    337             color_print(record.levelname, 'brown', end='')
    338         else:
--> 339             color_print(record.levelname, 'red', end='')
    340         print(": {0} [{1:s}]".format(record.msg, record.origin))
    341

c:\python27\lib\site-packages\astropy\utils\console.py in color_print(*args, **k wargs)
    228
    229     write = file.write
--> 230     if isatty(file) and USE_COLOR():
    231         for i in xrange(0, len(args), 2):
    232             msg = args[i]

c:\python27\lib\site-packages\astropy\config\configuration.py in
__call__(self)
    334
    335         #get the value from the relevant `configobj.ConfigObj` object
--> 336         sec = get_config(self.module)
    337         if self.name not in sec:
    338             self.set(self.defaultvalue)

c:\python27\lib\site-packages\astropy\config\configuration.py in get_config(pack ageormod, reload)
    400
    401     from .paths import get_config_dir
--> 402     from ..utils import find_current_module
    403
    404     if packageormod is None:

SystemError: Parent module 'astropy' not loaded, cannot perform relative import The original exception:

In [2]: import astropy
--------------------------------------------------------------------------- ImportError                               Traceback (most recent call last) <ipython-input-2-d192094ef7da> in <module>()
----> 1 import astropy

c:\python27\lib\site-packages\astropy\__init__.py in <module>()
    125 if not _ASTROPY_SETUP_:
    126     from .logger import _init_log
--> 127     from . import config
    128
    129     import os

ImportError: cannot import name config

In [3]:
更多信息:
这是一个与所描述的问题类似的问题,但我不想使用Canopy或Anaconda。

这可能与您链接的问题重复。我从来没有能够重现这一点,但我认为这实际上与在Windows上导入一个编译模块失败有关,可能是由于msvcrt不匹配或类似的原因。你介意把它作为副本合上吗?我有理由肯定这是真的。事实上,我觉得这甚至不是一个问题,而是一个应该放在Astropy的bug跟踪器上的问题,因为它一定与特定平台上的Windows构建有关。@iGuanaaut,这对我来说很好,但我没有代表来结束我的问题。。。但是,由于astropy github上建议的解决方案不起作用,我在这里发布了一个新的二进制文件,通过使用它来修复它。我现在相信问题在于二进制文件是如何构建的