1
import sklearn

I get this error:

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-9-b7c74cbf5af0> in <module>
----> 1 import sklearn

~\AppData\Roaming\Python\Python37\site-packages\sklearn\__init__.py in <module>
     78     # later is linked to the OpenMP runtime to make it possible to introspect
     79     # it and importing it first would fail if the OpenMP dll cannot be found.
---> 80     from . import _distributor_init  # noqa: F401
     81     from . import __check_build  # noqa: F401
     82     from .base import clone

~\AppData\Roaming\Python\Python37\site-packages\sklearn\_distributor_init.py in <module>
     16     # Pre-load the DLL stored in sklearn/.libs by convention.
     17     dll_path = op.join(op.dirname(__file__), '.libs', 'vcomp140.dll')
---> 18     WinDLL(op.abspath(dll_path))
     19 

~\Anaconda3\lib\ctypes\__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error)
    354 
    355         if handle is None:
--> 356             self._handle = _dlopen(self._name, mode)
    357         else:
    358             self._handle = handle

OSError: [WinError 193] %1 is not a valid Win32 application

please help me with this

AMC
  • 2,642
  • 7
  • 13
  • 35
  • Have you searched for your problem? https://stackoverflow.com/questions/56724023/oserror-winerror-193-1-is-not-a-valid-win32-application-when-trying-to-imp – Felix Kleine Bösing Apr 23 '20 at 09:34
  • We're going to need more information than this. Please see [ask], [help/on-topic]. – AMC Apr 24 '20 at 03:28

1 Answers1

0

Use environments, since you have conda as your package manager. Do the following:

  1. create environment with needed packages
  2. activate and work in that environment

Code:

# create and activate env called ml with Python 3.7 and jupyter lab and scikit-learn 
conda create -n ml python=3.7 scikit-learn jupyterlab
conda activate ml

# check that all is fine by print scikit-learn version
python -c "import sklearn;print(sklearn.__version__)"

# if no error, spin jupyter Lab
jupyter lab 

You can add more packages to your environment on command line:

conda install -n ml pandas requests

If you want to install pip packages. You must activate the correct environment first.

conda activate ml
python -m pip install geopy 

To deactivate conda deactivate

It is good practice to create project specific environments. Install only used packages.

Prayson W. Daniel
  • 14,191
  • 4
  • 51
  • 57