首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >安装scikit时出错-学习python3

安装scikit时出错-学习python3
EN

Stack Overflow用户
提问于 2018-01-01 01:27:08
回答 1查看 2.3K关注 0票数 1

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

代码语言:javascript
复制
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.

我试着进入源目录,输入他们说的话,但没有结果。这里有洞察力吗?

谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-01-01 03:24:27

如果您从Python2.x的源代码中安装了sklearn,如果您没有完全删除所有sklearn文件,它的一些二进制文件可能会持续存在。Python2.x和3.x非常不兼容,所以这可能是它无法构建的原因之一。

需要采取的几个步骤:

  1. 考虑在您的sklearn项目中使用virtualenv,特别是当您有许多不同的包或Python版本浮动时。这对于使用不同的Python包和库保持不同的开发环境是很好的。如果您还没有本指南,请跟随它。在创建virtualenv时,请确保在创建virtualenv时使用以下命令使用Python 3.x安装它: virtualenv -p python3 envname
  2. 如果从源代码构建:为您的Python3版本重新下载sklearn源代码,并将其放入您的虚拟环境中。严格遵循所有构建说明。这应该会给你一个干净的安装滑雪。
  3. 如果使用pip:安装,则激活您的虚拟主机,然后是:安装numpyscipy之后的pip install -U scikit-learn
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48046646

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档