从shell运行时发现的Python模块,但不是从IPython运行

时间:2016-03-15 21:46:28

标签: python ipython anaconda xgboost

我在Windows 7上安装了Anaconda python,然后使用这里的说明手动安装了xgboost包:How to install xgboost package in python (windows platform)?(它没有安装在anaconda下,但是在一个单独的目录中)

我将以下内容放在test.py中:

import sys
sys.path.append('C:<path>/xgboost/python-package')
import xgboost

当从命令行(例如,来自cygwin)导入时,导入正常。 但是,如果我使用Spyder IDE或Anaconda附带的IPython,我会得到

WindowsError                              Traceback (most recent call last) <ipython-input-14-afdaff4619ce> in <module>()
    ----> 1 import xgboost

    C:...\xgboost\python-package\xgboost\__init__.py in <module>()
      9 import os
     10
---> 11 from .core import DMatrix, Booster
     12 from .training import train, cv
     13 from . import rabit

C:...\xgboost\python-package\xgboost\core.py in <module>()
     81
     82 # load the XGBoost library globally
---> 83 _LIB = _load_lib()
     84
     85 def _check_call(ret):

C:...\xgboost\python-package\xgboost\core.py in _load_lib()
     75     if len(lib_path) == 0:
     76         return None
---> 77     lib = ctypes.cdll.LoadLibrary(lib_path[0])
     78     lib.XGBGetLastError.restype = ctypes.c_char_p
     79     return lib

C:...\Continuum\Anaconda2\lib\ctypes\__init__.pyc in Lo adLibrary(self, name)
    441
    442     def LoadLibrary(self, name):
--> 443         return self._dlltype(name)
    444
    445 cdll = LibraryLoader(CDLL)

C:...continuum\Anaconda2\lib\ctypes\__init__.pyc in __ init__(self, name, mode, handle, use_errno, use_last_error)
    363
    364         if handle is None:
--> 365             self._handle = _dlopen(self._name, mode)
    366         else:
    367             self._handle = handle

WindowsError: [Error 126] The specified module could not be found

我检查过sys.executable,我在shell和IPython中运行相同的python。打印sys.path显示在两种情况下正确的位置都是路径的一部分。知道发生了什么吗?我真的很想能够使用IDE。

0 个答案:

没有答案