1

I am getting started with machine learning in Python. So I was reading a tutorial on how to get started. article asked me to install some necessary libraries including numpy, matplotlib, scipy, pandas and sklearn, I looked up in PyCharm interpreter settings and it showed me that It already have all of them, installed. But when I try to import them. Specifically, sklearn, it throws this error.

Traceback (most recent call last):
  File "C:/Users/iMacPro 2K19/PycharmProjects/Machine Learning/main.py", line 6, in <module>
    import sklearn
  File "C:\Users\iMacPro 2K19\AppData\Local\Programs\Python\Python37-32\lib\site-packages\sklearn\__init__.py", line 82, in <module>
    from .base import clone
  File "C:\Users\iMacPro 2K19\AppData\Local\Programs\Python\Python37-32\lib\site-packages\sklearn\base.py", line 20, in <module>
    from .utils import _IS_32BIT
  File "C:\Users\iMacPro 2K19\AppData\Local\Programs\Python\Python37-32\lib\site-packages\sklearn\utils\__init__.py", line 28, in <module>
    from .validation import (as_float_array,
ImportError: cannot import name 'as_float_array' from 'sklearn.utils.validation' (C:\Users\iMacPro 2K19\AppData\Local\Programs\Python\Python37-32\lib\site-packages\sklearn\utils\validation.py)

Process finished with exit code 1

if helpful, here's my code too..

import sys
import scipy
import numpy
import matplotlib
import pandas
import sklearn
# Python Version
print('Python {0}'.format(sys.version))
# scipy
print('scipy {0}'.format(scipy.__version__))
# numpy
print('numpy {0}'.format(numpy.__version__))
# matplotlib
print('matplotlib {0}'.format(matplotlib.__version__))
# pandas
print('pandas {0}'.format(pandas.__version__))
# sklearn
print('sklearn {0]'.format(sklearn.__version__))

I'm running win7 x64. python 3.7.3, scipy 1.3.2, numpy 1.17.4, matplotlib 3.1.2 and pandas 0.25.3. and someone also please tell me if sklearn and scikit-learn are different or both are just same with different names because i have sklearn version 0.0 and scikit-learn version 0.22.1. and when importing I'm only able to import sklearn, scikit-learn does not show as available when trying to import. I don't think that there's any problem within the code. Maybe sklearn is not compatible with my version of python. I don't know for sure. Any help would be much appreciated. Thanks.

Gokul nath
  • 494
  • 2
  • 8
  • 17
Abdullah
  • 23
  • 1
  • 7
  • I'm guessing this link will give you a little insight to how to solve the issues. If it still doesn't help, please let me know :) https://stackoverflow.com/questions/32675024/getting-pycharm-to-import-sklearn – Alen S Thomas Mar 24 '20 at 07:07
  • @AlenSThomas I'm sorry but it didn't work.. I had visited this link some hours ago and tried those solutions, but none worked. I've both scikit-learn and sklearn packages installed and i import with name **sklearn** (eg. import sklearn). But it doesn't work. – Abdullah Mar 24 '20 at 07:33
  • You want to have the `scikit-learn` package only. See pypi: https://pypi.org/project/sklearn/ – LudvigH Mar 24 '20 at 07:38
  • I think the problem is due to 'print('sklearn {0]'.format(sklearn.__version__))'. Before .format method the braces should be as {} and not {]. Please see if this helps. – RAHUL MAURYA Mar 24 '20 at 07:56

1 Answers1

2

In the command promt try

pip install -U scikit-learn

After Try this code to test versions of your librarys into your python IDLE.

import sys
import scipy
import numpy
import matplotlib
import pandas
import sklearn
# Python Version
print('Python {0}'.format(sys.version))
# scipy
print('scipy {0}'.format(scipy.__version__))
# numpy
print('numpy {0}'.format(numpy.__version__))
# matplotlib
print('matplotlib {0}'.format(matplotlib.__version__))
# pandas
print('pandas {0}'.format(pandas.__version__))
# sklearn
print('sklearn {0}'.format(sklearn.__version__))

You can see in your terminal somthing with that in your otput console

Python 3.8.3 (default, Jul  2 2020, 17:30:36) [MSC v.1916 64 bit (AMD64)]
scipy 1.5.0
numpy 1.18.5
matplotlib 3.2.2
pandas 1.0.5
sklearn 0.23.1