'ValueError: source code string cannot contain null bytes while import sklearn

I'm trying to import MinMaxScaler from sklearn.preprocessing. when I run my code this error appears that refers to the import line:

ValueError: source code string cannot contain null bytes.

I checked and updated all of the requirements for scikit-learn and the error still appears. I also tried to open a blank python file with only this line :

from sklearn.preprocessing import MinMaxScaler

but it didn't help.

What can I do?

*I'm using windows 10.



Solution 1:[1]

I had the same error (with numpy module) and it was caused by a power outtage. the requirements.txt instalation with pip was interrupted resulting in a corrupted module.

I went manually to the site-packages folders, deleted numpy and installed it again using pip install numpy

After that problem was solved. Hope this helps!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MariusMihai92