安装scikit learn python3时出错

安装scikit learn python3时出错,python,python-3.x,scikit-learn,installation,Python,Python 3.x,Scikit Learn,Installation,因此,我能够为python2安装sklearn,但由于某些原因,我在为python3安装sklearn时遇到了问题。我得到这个错误: 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 ImportErro

因此,我能够为python2安装sklearn,但由于某些原因,我在为python3安装sklearn时遇到了问题。我得到这个错误:

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.
回溯(最近一次呼叫最后一次):
文件“/home/ajshack\u pg/sklearn/\uuuuuuu check\u build/\uuuuuuuuu init\uuuuuu.py”,第44行,在
from._check_build import check_build#noqa
ImportError:/home/ajshack\u pg/sklearn/\uuuuu check\u build/\uu check\u build.so:未定义符号:PyUnicodeUCS4\u DecodeUTF8
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
文件“/home/ajshack_pg/sklearn/_init__uuuuu.py”,第133行,在
从…起导入检查生成
文件“/home/ajshack\u pg/sklearn/\uuuuuuu check\u build/\uuuuuuuuu init\uuuuuuuuuu.py”,第46行,in
raise\U build\U错误(e)
文件“/home/ajshack\u pg/sklearn/\uuuuu check\u build/\uuuuuu init\uuuuuu.py”,第41行,在raise\u build\u error中
%s”“”%(e,local_dir”“.join(dir_content.strip(),msg))
ImportError:/home/ajshack\u pg/sklearn/\uuuuu check\u build/\uu check\u build.so:未定义符号:PyUnicodeUCS4\u DecodeUTF8
___________________________________________________________________________
/home/ajshack\u pg/sklearn/\uu检查\u构建的内容:
setup.py setup.pyc\uuuu init\uuuuuu.pyc
_检查\u build.so\u init\u.py
___________________________________________________________________________
似乎scikit学习尚未正确构建。
如果您已安装scikit“从源代码学习”,请不要忘记
要在使用包之前构建它:运行`python setup.py install`或
`在源目录中生成“”。
如果您使用过安装程序,请检查它是否适合您的需要
Python版本、操作系统和平台。
我试图进入源代码目录,输入他们说的内容,但没有用。这里有什么见解吗


谢谢!

如果您为Python 2.x安装了sklearn from source,如果您没有完全删除所有sklearn文件,它的一些二进制文件可能会一直存在。Python 2.x和3.x彼此非常不兼容,因此这可能是它无法生成的原因

需要采取的几个步骤:

  • 考虑在sklearn项目中使用virtualenv,特别是当您有很多不同的软件包或Python版本时。这对于隔离不同Python软件包和库的不同开发环境非常有用。如果您还没有,请遵循。创建virtualenv时,请确保安装在创建virtualenv时,使用以下命令将其与Python 3.x兼容:

    virtualenv-p python3 envname

  • 如果从源代码构建:重新下载Python3版本的sklearn源代码,并将其放在virtualenv中。请严格遵循所有构建说明。这将为您提供一个干净的sklearn安装

  • 如果使用pip安装:激活您的VirtualNV,然后:
    pip安装-U scikit安装后学习
    numpy
    scipy


  • 你是如何安装这个软件包的?你使用的是什么操作系统?@amosegellinux从外观上看(这个.so文件让我想到了这一点)。