Amanda.py
Amanda.py

Reputation: 113

error installing 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 <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.

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

Thanks!

Upvotes: 1

Views: 2582

Answers (1)

optimizedp
optimizedp

Reputation: 132

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:

  1. 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

  2. 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.

  3. If installing with pip: Activate your virtualenv, then: pip install -U scikit-learn after installing numpy and scipy.

Upvotes: 1

Related Questions