2016-10-06 133 views
0

我有安裝在OS X上的Anaconda。我能夠從python終端和IPython終端導入sklearn。但是,當我嘗試從Jupyter筆記本導入sklearn,我得到以下錯誤:Scikit學習無法只導入Jupyter筆記本

--------------------------------------------------------------------------- 
ImportError        Traceback (most recent call last) 
<ipython-input-4-8fd979e02004> in <module>() 
----> 1 import sklearn 

/Users/joe/anaconda/envs/data_env/lib/python3.5/site-packages/sklearn/__init__.py in <module>() 
    55 else: 
    56  from . import __check_build 
---> 57  from .base import clone 
    58  __check_build # avoid flakes unused variable error 
    59 

/Users/joe/anaconda/envs/data_env/lib/python3.5/site-packages/sklearn/base.py in <module>() 
    10 from scipy import sparse 
    11 from .externals import six 
---> 12 from .utils.fixes import signature 
    13 from .utils.deprecation import deprecated 
    14 from .exceptions import ChangedBehaviorWarning as _ChangedBehaviorWarning 

/Users/joe/anaconda/envs/data_env/lib/python3.5/site-packages/sklearn/utils/__init__.py in <module>() 
     9 
    10 from .murmurhash import murmurhash3_32 
---> 11 from .validation import (as_float_array, 
    12       assert_all_finite, 
    13       check_random_state, column_or_1d, check_array, 

/Users/joe/anaconda/envs/data_env/lib/python3.5/site-packages/sklearn/utils/validation.py in <module>() 
    16 
    17 from ..externals import six 
---> 18 from ..utils.fixes import signature 
    19 from .deprecation import deprecated 
    20 from ..exceptions import DataConversionWarning as _DataConversionWarning 

/Users/joe/anaconda/envs/data_env/lib/python3.5/site-packages/sklearn/utils/fixes.py in <module>() 
    288  from ._scipy_sparse_lsqr_backport import lsqr as sparse_lsqr 
    289 else: 
--> 290  from scipy.sparse.linalg import lsqr as sparse_lsqr 
    291 
    292 

/Users/joe/anaconda/envs/data_env/lib/python3.5/site-packages/scipy/sparse/linalg/__init__.py in <module>() 
    110 from __future__ import division, print_function, absolute_import 
    111 
--> 112 from .isolve import * 
    113 from .dsolve import * 
    114 from .interface import * 

/Users/joe/anaconda/envs/data_env/lib/python3.5/site-packages/scipy/sparse/linalg/isolve/__init__.py in <module>() 
     4 
     5 #from info import __doc__ 
----> 6 from .iterative import * 
     7 from .minres import minres 
     8 from .lgmres import lgmres 

/Users/joe/anaconda/envs/data_env/lib/python3.5/site-packages/scipy/sparse/linalg/isolve/iterative.py in <module>() 
     5 __all__ = ['bicg','bicgstab','cg','cgs','gmres','qmr'] 
     6 
----> 7 from . import _iterative 
     8 
     9 from scipy.sparse.linalg.interface import LinearOperator 

ImportError: dlopen(/Users/joe/anaconda/envs/data_env/lib/python3.5/site-packages/scipy/sparse/linalg/isolve/_iterative.so, 2): Library not loaded: /usr/local/lib/libgcc_s.1.dylib 
    Referenced from: /Users/joe/anaconda/envs/data_env/lib/python3.5/site-packages/scipy/sparse/linalg/isolve/_iterative.so 
    Reason: image not found 

我可以導入numpy的,SciPy的,和大熊貓從Jupyter筆記本罰款。這只是sklearn失敗。

我也嘗試過創建一個新的conda環境(conda create -n test_env jupyter notebook matplotlib scipy numpy pandas scikit-learn),但該錯誤在新環境中也存在。

+0

嘗試打印哪個python解釋器使用 – Julius

+0

安裝jupyter它看起來是一樣的。 ''python'生成'/ Users/joe/anaconda/bin/python'和'sys.executable'會在Jupyter筆記本或標準Python或IPython終端中產生相同結果。 –

回答

2

我設法弄清楚發生了什麼,所以我會在這裏發佈我的解決方案,以防其他人遇到同樣的問題。事實證明,當我安裝另一個軟件時,我修改了我的.bashrc文件中的DYLD_FALLBACK_LIBRARY_PATH環境變量。將此環境變量恢復爲其默認值可以解決我的問題。 (順便說一句,scikit-learn也沒有在標準的Python終端中導入,我最初並沒有意識到這一點,因爲我在一個環境中測試了Python終端,在這個環境中,我不小心將環境變量恢復到了它們的環境變量默認情況下,覆蓋我在我的.bashrc文件中所做的更改。)