作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想使用 auto-sklearn .我使用了这个 document 中的代码.所有软件包都已安装。但是我遇到了这样的错误。
!curl https://raw.githubusercontent.com/automl/auto-sklearn/master/requirements.txt | xargs -n 1 -L 1 pip install
!pip install auto-sklearn
import autosklearn.classification
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-9-f7b2b884019b> in <module>()
24 from keras.callbacks import EarlyStopping
25 from keras.metrics import categorical_accuracy
---> 26 import autosklearn.classification
27
28
/usr/local/lib/python3.6/dist-packages/autosklearn/classification.py in <module>()
----> 1 from autosklearn.estimators import AutoSklearnClassifier
/usr/local/lib/python3.6/dist-packages/autosklearn/estimators.py in <module>()
3 import numpy as np
4
----> 5 from autosklearn.automl import AutoMLClassifier, AutoMLRegressor
6 from autosklearn.util.backend import create
/usr/local/lib/python3.6/dist-packages/sklearn/ensemble/base.py in <module>()
12 from ..base import BaseEstimator
13 from ..base import MetaEstimatorMixin
---> 14 from ..utils import _get_n_jobs, check_random_state
15 from ..externals import six
16 from abc import ABCMeta, abstractmethod
ImportError: cannot import name '_get_n_jobs'
我试过了 this advice这是关于指定安装文件夹。但我仍然有同样的错误......
谁能帮帮我?
我尝试了 tidylobster 和 CrepeGoat 解决方案。然后我收到另一条错误消息,如下所示。
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py in _dep_map(self)
2896 try:
-> 2897 return self.__dep_map
2898 except AttributeError:
/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py in __getattr__(self, attr)
2690 if attr.startswith('_'):
-> 2691 raise AttributeError(attr)
2692 return getattr(self._provider, attr)
AttributeError: _DistInfoDistribution__dep_map
During handling of the above exception, another exception occurred:
AttributeError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py in _parsed_pkg_info(self)
2887 try:
-> 2888 return self._pkg_info
2889 except AttributeError:
/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py in __getattr__(self, attr)
2690 if attr.startswith('_'):
-> 2691 raise AttributeError(attr)
2692 return getattr(self._provider, attr)
AttributeError: _pkg_info
During handling of the above exception, another exception occurred:
FileNotFoundError Traceback (most recent call last)
<ipython-input-2-e20ebb276309> in <module>()
5 get_ipython().system('pip install auto-sklearn')
6
----> 7 import autosklearn.classification
/usr/local/lib/python3.6/dist-packages/autosklearn/__init__.py in <module>()
16 '''
17
---> 18 dependencies.verify_packages(__MANDATORY_PACKAGES__)
19
20 if os.name != 'posix':
/usr/local/lib/python3.6/dist-packages/autosklearn/util/dependencies.py in verify_packages(packages)
25 operation = match.group('operation1')
26 version = match.group('version1')
---> 27 _verify_package(name, operation, version)
28 else:
29 raise ValueError('Unable to read requirement: %s' % package)
/usr/local/lib/python3.6/dist-packages/autosklearn/util/dependencies.py in _verify_package(name, operation, version)
32 def _verify_package(name, operation, version):
33 try:
---> 34 module = pkg_resources.get_distribution(name)
35 installed_version = LooseVersion(module.version)
36 except pkg_resources.DistributionNotFound:
/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py in get_distribution(dist)
477 dist = Requirement.parse(dist)
478 if isinstance(dist, Requirement):
--> 479 dist = get_provider(dist)
480 if not isinstance(dist, Distribution):
481 raise TypeError("Expected string, Requirement, or Distribution", dist)
/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py in get_provider(moduleOrReq)
353 """Return an IResourceProvider for the named module or requirement"""
354 if isinstance(moduleOrReq, Requirement):
--> 355 return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
356 try:
357 module = sys.modules[moduleOrReq]
/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py in require(self, *requirements)
896 included, even if they were already activated in this working set.
897 """
--> 898 needed = self.resolve(parse_requirements(requirements))
899
900 for dist in needed:
/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py in resolve(self, requirements, env, installer, replace_conflicting, extras)
790
791 # push the new requirements onto the stack
--> 792 new_requirements = dist.requires(req.extras)[::-1]
793 requirements.extend(new_requirements)
794
/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py in requires(self, extras)
2633 def requires(self, extras=()):
2634 """List of Requirements needed for this distro if `extras` are used"""
-> 2635 dm = self._dep_map
2636 deps = []
2637 deps.extend(dm.get(None, ()))
/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py in _dep_map(self)
2897 return self.__dep_map
2898 except AttributeError:
-> 2899 self.__dep_map = self._compute_dependencies()
2900 return self.__dep_map
2901
/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py in _compute_dependencies(self)
2906 reqs = []
2907 # Including any condition expressions
-> 2908 for req in self._parsed_pkg_info.get_all('Requires-Dist') or []:
2909 reqs.extend(parse_requirements(req))
2910
/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py in _parsed_pkg_info(self)
2888 return self._pkg_info
2889 except AttributeError:
-> 2890 metadata = self.get_metadata(self.PKG_INFO)
2891 self._pkg_info = email.parser.Parser().parsestr(metadata)
2892 return self._pkg_info
/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py in get_metadata(self, name)
1408 if not self.egg_info:
1409 return ""
-> 1410 value = self._get(self._fn(self.egg_info, name))
1411 return value.decode('utf-8') if six.PY3 else value
1412
/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py in _get(self, path)
1520
1521 def _get(self, path):
-> 1522 with open(path, 'rb') as stream:
1523 return stream.read()
1524
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/lib/python3.6/dist-packages/scikit_learn-0.20.1.dist-info/METADATA'
我搜索了 not found scikit_learn-0.20.1.dist-info/METADATA .但我还没有找到好的答案。
最佳答案
使用 sudo apt-get
安装 swig,如下所示 the AutoScikitLearn instructions for Ubuntu ,并执行 !sudo apt-get upgrade
以获取所有内容的最新版本。全文:
!sudo apt-get update
!sudo apt-get install build-essential swig
!sudo apt-get upgrade
!curl https://raw.githubusercontent.com/automl/auto-sklearn/master/requirements.txt | xargs -n 1 -L 1 pip install
!pip install auto-sklearn
import autosklearn.classification
所以我重新运行我的代码,我得到的错误非常很奇怪。因为我得到了与@Nori 描述的相同的错误,但是它们在第三次尝试导入时消失了。知道了这一点,就很容易编写一个肮脏的 hack 来绕过它:
!sudo apt-get install build-essential swig
!curl https://raw.githubusercontent.com/automl/auto-sklearn/master/requirements.txt | xargs -n 1 -L 1 pip install
!pip install auto-sklearn
for _ in range(3):
try:
import autosklearn.classification
break
except:
pass
else:
raise ImportError("failed to import from autosklearn")
但不幸的是,我零知道为什么会这样。
关于python - 如何在 Google Colab 上安装 auto-sklearn?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53839948/
我是一名优秀的程序员,十分优秀!