How to install dlib for python3 in Ubuntu 14.04

28,369

Found solution by myself but thanks @edwinksl for his tip. In order to install dlib for python3 it's better to use pip:

pip install dlib

You will need boost python. To get it:

sudo apt-get install libboost-all-dev

If you have "Could NOT find PythonLibs (missing: PYTHON_LIBRARIES) (Required is at least version "3.4")" error make sure you have cmake > 2.8 (In my case it is 3.2.2). To install cmake > 2.8:

sudo add-apt-repository ppa:george-edison55/cmake-3.x
sudo apt-get update
sudo apt-get install cmake

That solved the issue for me.

Share:
28,369

Related videos on Youtube

wasd
Author by

wasd

Trying to move from pythonier to pythonista =)

Updated on September 18, 2022

Comments

  • wasd
    wasd over 1 year

    I'm following this guide https://cmusatyalab.github.io/openface/setup/ of installation. I did:

     mkdir -p ~/src
     cd ~/src
     tar xf dlib-19.1.0.tar.gz
     cd dlib-19.1.0/python_examples
     mkdir build
     cd build
     cmake ../../tools/python
     cmake --build . --config Release
     sudo cp dlib.so /usr/local/lib/python3.4/dist-packages/
    

    It says that at this point I should be able to run import dlib, but if I run it from virtualenv gives me

    ImportError: No module named dlib
    

    If I run it outside from virtualenv it gives:

    ImportError: dynamic module does not define init function (PyInit_dlib)
    

    What am I doing wrong? How to install dlib for python?

    UPD: I've tried same for Python2:

    sudo cp dlib.so /usr/local/lib/python2.7/dist-packages/
    

    and it worked for python2. So how to do the same for python3?

    • steeldriver
      steeldriver over 7 years
      Are you aware that (at least by default) python is python2 on Ubuntu 14.04? Are you trying to import dlib from python or from python3?
    • wasd
      wasd over 7 years
      Sure, I tried both python2 and python3, but still no effect
    • edwinksl
      edwinksl over 7 years
      @wasd You said you are trying to run it from a virtualenv? Then you can just activate the virtualenv and use pip to install dlib. Or if yo have dlib installed globally, you can create a virtualenv with the --system-site-packages option.
    • wasd
      wasd over 7 years
      @edwinksl If I try to install dlib with pip it gives CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.c‌​make:108 (message): Could NOT find PythonLibs (missing: PYTHON_LIBRARIES) (Required is at least version "3.4")
  • edwinksl
    edwinksl over 7 years
    Awesome, I hadn't noticed cmake was only at version 2.8 in Ubuntu 14.04.