我想使用auto-sklearn.i使用了此文档中的代码。安装了所有软件包。但是我有这样的错误。
!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'
我尝试了有关指定安装文件夹的建议。但是我仍然有同样的错误...
有人可以给我一只手吗?
添加
我尝试了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'
我搜索找不到scikit_learn-0.20.1.dist-info/metadata。但是我没有找到好的答案。
使用 sudo apt-get
安装swigubuntu 的自动说明,并执行!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所述相同,但是它们在第三次尝试导入的尝试中消失了。知道这一点,很容易写一个肮脏的骇客来解决它:
!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")
,但不幸的是,我有零知道为什么是这种情况。
您还安装了建筑包吗?我刚刚尝试了以下步骤,并且可以正确奏效。
!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
import autosklearn.classification
在依赖性安装过程中,正在编译一些软件包。因此,如果您在!curl ...
之前没有安装建筑物,这可能是原因。