我最近安装了PyCharm。我将项目解释器设置为python3.7
安装。我已经安装了sklearn软件包,并且可以在“项目解释器”窗口中看到它。
但是,当我尝试导入sklearn时,会引发如下所示的错误。
Traceback (most recent call last):
File "C:\Users\Rad_admin\AppData\Roaming\Python\Python37\site-packages\IPython\core\interactiveshell.py", line 3267, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-19-b7c74cbf5af0>", line 1, in <module>
import sklearn
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "C:\Users\Rad_admin\AppData\Local\Programs\Python\Python37\Lib\site-packages\lightgbm\sklearn.py", line 9, in <module>
from .basic import Dataset, LightGBMError
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ImportError: attempted relative import with no known parent package
我已经重新安装了pycharm和sklearn了多次。在调用import sklearn之前,我导入了numpy和lightgbm。