我想在本地运行程序,但在jupyter notebook中出现了一个错误“ImportError: No module named 'sklearn'”。当我在命令行中使用激活和非激活状态的carnd-term1环境时,都可以正常工作。
我已经使用pip、apt-get和conda安装了sklearn,并尝试了conda upgrade scikit-learn,同样在激活和非激活环境下进行了尝试。
(carnd-term1) matt@Malta:~/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) matt@Malta:~/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) matt@Malta:~/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) matt@Malta:~/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]:
在jupyter notebook中无法正常工作。
有任何想法吗?