简体   繁体   中英

Can't import MinMaxScaler “from sklearn.preprocessing import MinMaxScaler”

I run into the following error when running my script. Could someone please let me know what the issue could be? I have installed Sklearn on my system, and using "pip list" I can see 'sklearn 0.0" is present.

C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\pandas_datareader\compat\__init__.py:7: FutureWarning:

pandas.util.testing is deprecated. Use the functions in the public API at pandas.testing instead.

Traceback (most recent call last):
  File "app.py", line 9, in <module>
    import sklearn.preprocessing
  File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\sklearn\__init__.py", line 81, in <module>
    from . import __check_build  # noqa: F401
ImportError: cannot import name '__check_build' from partially initialized module 'sklearn' (most likely due to a circular import) (C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\sklearn\__init__.py)

Code:

import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import math
import pandas_datareader as web
import numpy as np
import pandas as pd
from sklearn.preprocessing import MinMaxScaler

So I found out what's causing this issue. some packages are not being installed due to file path length limit on windows. In order to fix this I had to: Type “regedit” in the Windows start menu to launch regedit.

Go to the Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem key.

Edit the value of the LongPathsEnabled property of that key and set it to 1.

Reinstall scikit-learn (ignoring the previous broken installation): pip install --exists-action=i scikit-learn

for more info visit: https://scikit-learn.org/stable/install.html#troubleshooting

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