2017-02-11 5 views
1

로컬 컴퓨터에서 실행하려고합니다. 오류가 발생했습니다 ImportError : jupyter 노트북에만 'sklearn'이라는 모듈이 없습니다. carnd-term1 env가 활성화되어 있고 비활성화 된 상태에서 명령 줄에서 python을 사용하면 올바르게 작동합니다.Jupyter NoteBook ImportError : 'sklearn'이라는 모듈이 없습니다.

저는 pip, apt-get 및 conda로 sklearn을 설치했습니다. 또한 콘도 업그레이드 scikit-learn을 시도했습니다. env 활성화 및 비활성화 모두.



...: (carnd-term1) [email protected]:~/sdc$ ipython 
    ...: Python 3.5.2 | packaged by conda-forge | (default, Jan 19 2017, 15:28:33) 
    ...: Type "copyright", "credits" or "license" for more information. 
    ...: 
    ...: IPython 5.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. 
    ...: 
    ...: In [1]: import sklearn 
    ...: 
    ...: In [2]: from sklearn.model_selection import train_test_split 
    ...: 
    ...: In [3]: (carnd-term1) [email protected]:~/sdc$ ipython 
    ...: ...: Python 3.5.2 | packaged by conda-forge | (default, Jan 19 2017, 15:28:33) 
    ...: ...: Type "copyright", "credits" or "license" for more information. 
    ...: ...: 
    ...: ...: IPython 5.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. 
    ...: ...: 
    ...: ...: In [1]: import sklearn 
    ...: ...: 
    ...: ...: In [2]: from sklearn.model_selection import train_test_split 
    ...: ...: 
    ...: ...: In [3]: 
(carnd-term1) [email protected]:~/sdc$ python3 
Python 3.5.2 | packaged by conda-forge | (default, Jan 19 2017, 15:28:33) 
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import sklearn 
>>> 
(carnd-term1) [email protected]:~/sdc$ conda upgrade scikit-learn 
Fetching package metadata ......... 
Solving package specifications: . 
# All requested packages already installed. 
# packages in environment at /home/matt/anaconda3/envs/carnd-term1: 
# 
scikit-learn 0.18.1 np112py35_1 


는 jupyter 노트북에서 작동하지 않습니다.

아이디어가 있으십니까?

+0

이 환경에 jupyter 노트북을 설치 했습니까? – darthbith

답변

0

일반적으로 두 환경이 같은 환경이 아님을 의미합니다. 가장 좋은 것은 sys.executable이며 기대 한 결과인지 확인하십시오. 그것은 당신이 기대 sys.executable 사용하지 않을 것 노트북이 있다면, 첫 번째 단계는 당신의 경로를 확인할 수 있습니다 :

which jupyter 
which jupyter-notebook 

가능성이 가장 높은 문제는 노트북 스택은 당신이 해결할 수있는 CONDA의 ENV에되지 않는 것입니다 로 :

conda install notebook 

두 번째 가능성은 당신이 당신의 ENV를 재정의 (ipython kernel install --user로 예를 들면)를 kernelspec를 설치 한 것입니다. 당신의 커널에 어디 있는지 볼 수 있습니다 : 당신이 같은 ENV에 설치된 IPython의 커널을 사용하려면

jupyter kernelspec list 

, 당신은 할 수 있습니다 :

conda install ipykernel 
ipython kernelspec install --sys-prefix 

다시 후 jupyter kernelspec list을 확인합니다.

관련 문제