Ujwal Tewari
Ujwal Tewari

Reputation: 1

Error while importing datasets from sklearn

import matplotlib.pyplot as plt
from sklearn import datasets
from sklearn import svm

it gives the following error-

Traceback (most recent call last):
  File "/home/songoku/PycharmProjects/untitled/sklearn.py", line 4, in <module>
    from sklearn import datasets
  File "/home/songoku/PycharmProjects/untitled/sklearn.py", line 4, in <module>
    from sklearn import datasets
ImportError: cannot import name 'datasets'

Upvotes: 0

Views: 939

Answers (2)

user298915
user298915

Reputation: 1

Try checking the version of sklearn first. The modules like data-sets and svm is not a part of sklearn packages (0.19 <) i.e less than version number 0.19.0.

You can check this on the command line: pip3 list

it shows you the version of all libraries installed by pip3.

Note: Always double check if you istalled the libraries as a part of anaconda or pip3

Upvotes: 0

MaxU - stand with Ukraine
MaxU - stand with Ukraine

Reputation: 210842

Rename /home/songoku/PycharmProjects/untitled/sklearn.py to something that differs from the SKLearn module name: sklearn.py

Upvotes: 1

Related Questions