Building Python packages succeeds, but package is improperly built

dotancohen

When running python3 setup.py build it ended with this:

x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.4/sklearn/linear_model/sag_fast.o -Lbuild/temp.linux-x86_64-3.4 -o build/lib.linux-x86_64-3.4/sklearn/linear_model/sag_fast.cpython-34m.so
running install_lib
creating /usr/local/lib/python3.4/dist-packages/sklearn
error: could not create '/usr/local/lib/python3.4/dist-packages/sklearn': Permission denied

Of course it could not write to /usr/local/lib/ as no sudo was used. I'm wary of using sudo for this step.

This was the end of sudo python3 setup.py install:

running install_egg_info
Writing /usr/local/lib/python3.4/dist-packages/scikit_learn-0.18.dev0.egg-info
running install_clib

Looks good to me. However, when I try to import sklearn I get this error:

$ python3
Python 3.4.3+ (default, Oct 14 2015, 16:03:50) 
[GCC 5.2.1 20151010] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sklearn
Traceback (most recent call last):
File "/home/dotancohen/code/scikit-learn/sklearn/__check_build/__init__.py", line 44, in <module>
    from ._check_build import check_build
ImportError: No module named 'sklearn.__check_build._check_build'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/dotancohen/code/scikit-learn/sklearn/__init__.py", line 56, in <module>
    from . import __check_build
File "/home/dotancohen/code/scikit-learn/sklearn/__check_build/__init__.py", line 46, in <module>
    raise_build_error(e)
File "/home/dotancohen/code/scikit-learn/sklearn/__check_build/__init__.py", line 41, in raise_build_error
    %s""" % (e, local_dir, ''.join(dir_content).strip(), msg))
ImportError: No module named 'sklearn.__check_build._check_build'
___________________________________________________________________________
Contents of /home/dotancohen/code/scikit-learn/sklearn/__check_build:
_check_build.c            setup.pyc                 __pycache__
_check_build.pyx          __init__.py               setup.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.
>>>

Should I run python3 setup.py build with sudo? This is on Kubuntu Linux 15.10:

$ uname -a
Linux loathe 4.2.0-16-generic #19-Ubuntu SMP Thu Oct 8 15:35:06 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

$ cat /etc/issue
Ubuntu 15.10 \n \l

Note that the Ubuntu-packaged version of python-scikits-learn is for Python 2 only, and I need Python 3.

dotancohen

I found this post which mentioned to configure which ATLAS (linear algebra package) version to use:

$ sudo update-alternatives --set libblas.so.3 /usr/lib/atlas-base/atlas/libblas.so.3
$ sudo update-alternatives --set liblapack.so.3 /usr/lib/atlas-base/atlas/liblapack.so.3

After that, I was happily surprised that in fact there was no longer a permissions issue, but I was getting this error on build instead:

sklearn/__check_build/_check_build.c:4:20: fatal error: Python.h: No such file or directory

Therefore I went over the results of aptitude search python | grep dev and decided that the following packages might help:

$ sudo aptitude install python3-numpy-dev python3.5-dev libpython3.4-dev

And with that the package built properly and scikit-learn imports properly:

$ python3
Python 3.4.3+ (default, Oct 14 2015, 16:03:50) 
[GCC 5.2.1 20151010] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sklearn
>>>

I'm not sure which of the three packages was the critical package, probably libpython3.4-dev, but the issue is resolved.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Building Python Extension Packages for Launchpad

From Dev

Python Improperly configured URL

From Dev

python - Yield improperly usage

From Dev

Building software installer with built-in python on Windows

From Dev

Building software installer with built-in python on Windows

From Dev

Building QtTreePropertyBrowser package with pre-built Qt Creator

From Dev

Building packages with conda and python3k

From Dev

Programmatically building SSIS packages with EncryptSensitiveWithPassword and package-level connection managers

From Dev

Programmatically building SSIS packages with EncryptSensitiveWithPassword and package-level connection managers

From Dev

Unable to install locally built python package

From Dev

Is this inheritance schema suitable for building a python package on?

From Dev

Pip vs Package Manager for handling Python Packages

From Dev

Pip vs Package Manager for handling Python Packages

From Dev

Is it possible to package Python app into snap packages?

From Dev

xcodebuild fails, but building from Xcode succeeds

From Java

How to avoid reinstalling packages when building Docker image for Python projects?

From Dev

Can I use my OctopusDeploy built-in Package Repository in Manage NuGet Packages?

From Dev

Can I use my OctopusDeploy built-in Package Repository in Manage NuGet Packages?

From Dev

DEB: multi-package, ignore installation of some files during packages building

From Dev

Why is Python 3 looking in my Python 2.7 package directory for packages?

From Dev

How to avoid building C library with my python package?

From Dev

Can I make a python package depend on different packages by OS?

From Dev

Install python package into directory relative to site-packages

From Dev

Should I list a TypeScript package as dependencies when I just want it's typing? I'm building packages as well

From Dev

Difference between building distribution packages with python3 and python2?

From Dev

Building R packages with Packrat and AppVeyor

From Dev

No speex packages for freeswitch building on Ubuntu

From Dev

Building packages from launchpad respository

From Dev

Tool or script to extract a list of non-built-in modules/packages in a Python project/repo?

Related Related

  1. 1

    Building Python Extension Packages for Launchpad

  2. 2

    Python Improperly configured URL

  3. 3

    python - Yield improperly usage

  4. 4

    Building software installer with built-in python on Windows

  5. 5

    Building software installer with built-in python on Windows

  6. 6

    Building QtTreePropertyBrowser package with pre-built Qt Creator

  7. 7

    Building packages with conda and python3k

  8. 8

    Programmatically building SSIS packages with EncryptSensitiveWithPassword and package-level connection managers

  9. 9

    Programmatically building SSIS packages with EncryptSensitiveWithPassword and package-level connection managers

  10. 10

    Unable to install locally built python package

  11. 11

    Is this inheritance schema suitable for building a python package on?

  12. 12

    Pip vs Package Manager for handling Python Packages

  13. 13

    Pip vs Package Manager for handling Python Packages

  14. 14

    Is it possible to package Python app into snap packages?

  15. 15

    xcodebuild fails, but building from Xcode succeeds

  16. 16

    How to avoid reinstalling packages when building Docker image for Python projects?

  17. 17

    Can I use my OctopusDeploy built-in Package Repository in Manage NuGet Packages?

  18. 18

    Can I use my OctopusDeploy built-in Package Repository in Manage NuGet Packages?

  19. 19

    DEB: multi-package, ignore installation of some files during packages building

  20. 20

    Why is Python 3 looking in my Python 2.7 package directory for packages?

  21. 21

    How to avoid building C library with my python package?

  22. 22

    Can I make a python package depend on different packages by OS?

  23. 23

    Install python package into directory relative to site-packages

  24. 24

    Should I list a TypeScript package as dependencies when I just want it's typing? I'm building packages as well

  25. 25

    Difference between building distribution packages with python3 and python2?

  26. 26

    Building R packages with Packrat and AppVeyor

  27. 27

    No speex packages for freeswitch building on Ubuntu

  28. 28

    Building packages from launchpad respository

  29. 29

    Tool or script to extract a list of non-built-in modules/packages in a Python project/repo?

HotTag

Archive