【问题标题】:error installing scikit-learn python3安装 scikit-learn python3 时出错
【发布时间】:2018-01-01 01:27:08
【问题描述】:

所以我能够为 python2 安装 sklearn,但由于某种原因,我在为 python3 做同样的事情时遇到了问题。我收到此错误:

Traceback (most recent call last):
  File "/home/ajshack_pg/sklearn/__check_build/__init__.py", line 44, in <module>
    from ._check_build import check_build  # noqa
ImportError: /home/ajshack_pg/sklearn/__check_build/_check_build.so: undefined symbol: PyUnicodeUCS4_DecodeUTF8

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ajshack_pg/sklearn/__init__.py", line 133, in <module>
    from . import __check_build
  File "/home/ajshack_pg/sklearn/__check_build/__init__.py", line 46, in <module>
    raise_build_error(e)
  File "/home/ajshack_pg/sklearn/__check_build/__init__.py", line 41, in raise_build_error
    %s""" % (e, local_dir, ''.join(dir_content).strip(), msg))
ImportError: /home/ajshack_pg/sklearn/__check_build/_check_build.so: undefined symbol: PyUnicodeUCS4_DecodeUTF8
___________________________________________________________________________
Contents of /home/ajshack_pg/sklearn/__check_build:
setup.py                  setup.pyc                 __init__.pyc
_check_build.so           __init__.py
___________________________________________________________________________
It seems that scikit-learn has not been built correctly.

If you have installed scikit-learn from source, please do not forget
to build the package before using it: run `python setup.py install` or
`make` in the source directory.

If you have used an installer, please check that it is suited for your
Python version, your operating system and your platform.

我试图进入源目录并输入他们所说的无济于事。这里有什么见解吗?

谢谢!

【问题讨论】:

  • 你是如何安装这个包的?您使用的是什么操作系统?
  • @AmosEgel Linux 的外观(.so 文件让我这么认为)。

标签: python python-3.x scikit-learn installation


【解决方案1】:

如果您从 Python 2.x 的源代码安装 sklearn,如果您没有完全删除所有 sklearn 文件,它的一些二进制文件可能会保留。 Python 2.x 和 3.x 彼此完全不兼容,所以这可能是它无法构建的原因。

几个步骤:

  1. 考虑为您的 sklearn 项目使用 virtualenv,尤其是当您有很多不同的包或 Python 版本时。它非常适合将不同的开发环境与不同的 Python 包和库保持隔离。如果您还没有,请关注this guide。创建 virtualenv 时,请确保在创建 virtualenv 时使用以下命令将其与 Python 3.x 一起安装:

    virtualenv -p python3 envname

  2. 如果从源代码构建:为您的 Python 3 版本重新下载 sklearn 源代码并将其放置在您的 virtualenv 中。严格遵循所有构建说明。这应该会给你一个全新的 sklearn 安装。

  3. 如果使用 pip 安装: 激活您的 virtualenv,然后: 安装numpyscipy后的pip install -U scikit-learn

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-11-14
    • 2017-08-19
    • 1970-01-01
    • 2014-06-27
    • 2021-02-01
    • 1970-01-01
    • 2016-02-05
    相关资源
    最近更新 更多