简体   繁体   中英

Cannot import sklearn on spyder

I installed anaconda 3 full package, when I try to import sklearn module on spyder it give me the following error:

import sklearn
Traceback (most recent call last):

  File "<ipython-input-1-8fd979e02004>", line 1, in <module>
    import sklearn

  File "C:\Users\username\Documents\Python Scripts\sklearn.py", line 11, in <module>
    from sklearn.naive_bayes import GaussianNB

ImportError: No module named 'sklearn.naive_bayes'; 'sklearn' is not a package

I am able to import sklearn on IPython, this must be a problem unique to Spyder, anyone got any idea why this is the case ?

I ran into the same problem with my Ubuntu 16.04 installation. I checked ipython console and ipython3 console and saw that sklearn loaded in ipython, the python 2 default, but not ipython3.

You will need to use pip3 to install scikit-learn. Run the following: sudo apt-get update, then, sudo apt-get -y install python3-pip

After that run: sudo pip3 install scikit-learn

I ran across the same problem recently and haven't been able to solve it that way. Nevertheless, while running through an update problem I noticed the utilization of spyder through Anaconda solved all my problems.

I uninstalled my basic spider and re-installed it through Ananconda where we're able to automatically manage spyder versions and avoid the libraries' problems.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM