我正在尝试在python 2上运行一些代码,但不断收到此错误No module named model_selection
。我检查了一下,出于某种原因,我的python2上的sklearn是版本0.17,但是当我尝试更新时,它说我已经有一个更新的版本,但这是针对python 3的。我如何专门为python 2更新sklearn?
运行pip install -U scikit-learn
时出现错误:Requirement already up-to-date: scikit-learn in /home/ruven/anaconda3/lib/python3.6/site-packages (0.19.2)
运行python2.7 -m pip install -U scikit-learn
时出现错误:
Collecting scikit-learn
Using cached https://files.pythonhosted.org/packages/bc/67/370aa248f54769a56216707ad7b9af19745e85a603fafa47bde353f327fb/scikit_learn-0.19.2-cp27-cp27mu-manylinux1_x86_64.whl
Installing collected packages: scikit-learn
Found existing installation: scikit-learn 0.17
Cannot uninstall 'scikit-learn'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
答案 0 :(得分:2)
使用以下命令解决:
sudo easy_install --upgrade scikit-learn
答案 1 :(得分:2)
sudo easy_install-升级scikit-学习