import sklearn
我收到此错误:
---------------------------------------------------------------------------
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
请帮助我
答案 0 :(得分:0)
请使用环境,因为您已经将conda作为包管理器。请执行以下操作:
代码:
# 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
您可以在命令行中将更多软件包添加到您的环境中:
conda install -n ml pandas requests
如果要安装pip软件包。您必须先激活正确的环境。
conda activate ml
python -m pip install geopy
停用
conda deactivate
优良作法是创建项目特定的环境。仅安装使用过的软件包。