0

This popped up when I try to import sklearn.

(base) C:\Users\ASUS>python                                                                                             
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] on win32                     
Type "help", "copyright", "credits" or "license" for more information.                                                                      
>>> import sklearn                                                                                                              
Traceback (most recent call last):                                                                                        
   File "<stdin>", line 1, in <module>                                                                                   
ImportError: bad magic number in 'sklearn': b'\x03\xf3\r\n'                                                             
>>>

I have tried to uninstall and reinstall Anaconda twice. Each time I reinstall, even before I'm trying to "conda install scikit-learn", this error persist. I have tried "conda uninstall scikit-learn" "conda uninstall sklearn" "pip uninstall scikit-learn", "pip uninstall sklearn" and trying to install it back but nothing seems to solve the problem.

This is what happened when I try to "find . -name "*.pyc" -delete"

(base) C:\Users\ASUS>find . -name "*.pyc" -delete                                                                       
Access denied - .                                                                                                       
File not found - -NAME                                                                                                  
File not found - -DELETE

OS: Windows 10

2 Answers2

0

This Post can help you.

You need to delete python bytecode file
Deleting all .pyc files will fix "Bad Magic Number" error

find . -name "*.pyc" -delete
jits_on_moon
  • 827
  • 6
  • 10
0

I find my own workaround for this problem. Mr. J's answer and the one from this post didn't solve my problem. So for anyone that experiencing the same thing: My workaround is to Uninstall Anaconda all over again, and install Anaconda Python 2.7 version. From there, create a new anaconda environment in your Python's version of choice. Tadaa fixed.