由于有多个python库不兼容_安装scikit-learn python3时出错

So I was able to install sklearn for python2 but for some reason I having issues with doing the same for python3. I am getting this error:

Traceback (most recent call last):

File "/home/ajshack_pg/sklearn/__check_build/__init__.py", line 44, in

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 "", line 1, in

File "/home/ajshack_pg/sklearn/__init__.py", line 133, in

from . import __check_build

File "/home/ajshack_pg/sklearn/__check_build/__init__.py", line 46, in

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.

I tried to go into the source directory and type in what they say to no avail. Any insight here?

Thanks!

解决方案

If you installed sklearn from source for Python 2.x, some of its binaries may have persisted if you didn't fully remove all sklearn files. Python 2.x and 3.x are quite incompatible with each other, so this might be a reason why it's failing to build.

A few steps to take:

Consider using a virtualenv for your sklearn projects, especially if you have a lot of different packages or Python versions floating around. It's great for keeping different development environments with different Python packages and libraries isolated. Follow this guide if you don't have it already. When creating your virtualenv, make sure to install it with Python 3.x by using this command when creating your virtualenv:

virtualenv -p python3 envname

If building from source: Redownload the sklearn source for your Python 3 version and place it in your virtualenv. Closely follow all build instructions. That should hopefully give you a clean install of sklearn.

If installing with pip: Activate your virtualenv, then:

pip install -U scikit-learn after installing numpy and scipy.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值