2017-02-11 5 views
1

Ich versuche, auf meinem lokalen Rechner zu laufen. Ich bekomme einen Fehler ImportError: Kein Modul mit dem Namen 'sklearn' nur in jupyter Notebook Es funktioniert gut, wenn ich Python von der Befehlszeile beide mit dem carnd-term1 env aktiviert und deaktiviert verwenden.Jupyter Notebook ImportError: Kein Modul namens 'sklearn'

Ich habe sklearn mit pip, apt-get und conda installiert. Auch versucht conda upgrade scikit-lernen. Beide mit dem env aktiv und deaktiviert.


(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 

(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$ 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]: 

von jupyter Notebook funktioniert nicht.

Irgendwelche Ideen?

+0

Haben Sie Jupyter Notebook in dieser Umgebung installiert? – darthbith

Antwort

0

Dies bedeutet im Allgemeinen, dass die beiden nicht die gleiche Umgebung sind. Die beste Sache zu überprüfen ist sys.executable und stellen Sie sicher, dass es das ist, was Sie erwarten. Wenn es das Notebook ist das nicht ist mit der sys.executable Sie erwarten, kann der erste Schritt sein, die Pfade zu überprüfen:

which jupyter 
which jupyter-notebook 

Die wahrscheinlichste Problem ist, dass der Notebook-Stack in Ihrem Conda env ist, was Sie lösen können mit:

conda install notebook 

Die zweithäufigste ist wahrscheinlich, dass Sie eine kernelspec installiert haben (zB mit ipython kernel install --user) das ist Ihr env überschreiben. Sie können sehen, wo Ihre Kerne sind mit:

jupyter kernelspec list 

sicher, dass Sie den IPython Kernel in der gleichen env installiert haben, um zu machen, können Sie tun:

conda install ipykernel 
ipython kernelspec install --sys-prefix 

und überprüfen jupyter kernelspec list wieder nach.

Verwandte Themen