-1

I have some code I'm playing around with using dlib, but when i try to import dlib in my python code i get this error:

File "boom.py", line 32, in <module>
    from faceSwap import *
File "/home/user/coding/faceSwap.py", line 22, in <module>
import dlib
ImportError: libboost_python-py27.so.1.49.0: cannot open shared object file: No 
such file or directory

However when i run it as root - it runs just fine! However I dont want to run a daemon as root - so I'd love to fix this. I've tried to uninstall/reinstall dlib several times via PIP with no success.

When i check for the libary it does seem to be missing from root and user level accounts even though DLIB does in fact run when the python program is run as root:

user:

$ whereis  libboost_python-py27.so.1.49.0
libboost_python-py27.so.1.49:

root:

# whereis libboost_python-py27.so.1.49.0
libboost_python-py27.so.1.49:

Both root and user accounts are using the same python

 /usr/local/bin/python

The only clue i have is that the user account dlib fails looking for :

 /usr/lib/libboost_python-py27.so.1.49.0 

but the root one works and seems to be using:

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

Any ideas how I can work around this or fix it?

Fight Fire With Fire
  • 1,626
  • 3
  • 19
  • 28
  • Sounds like a silly question, but are you sure that your root and user are using the same python installation? Sometimes they can even share the same version number, which can get pretty confusing. When doing installation, did you try `\path\to\python.exe -m pip install dlib` ? – Daniel Scott Jan 07 '19 at 23:02
  • @DanielScott i checked this, they are using the same python - but it looks like its not always clear what it's points to path wise. Under root liboost can be found in /usr/local/lib/python2.7/dist-packages/dlib.so -- but it looks like non-root users dont have access to it when they import dlib -- in fact its looking for a file thats not there. – Fight Fire With Fire Jan 08 '19 at 02:55
  • @davedwards unfortunately that question and solution is nothing like my issue :( – Fight Fire With Fire Jan 08 '19 at 22:05
  • 1
    @FightFireWithFire thank you for your feedback, I will delete my suggestion – chickity china chinese chicken Jan 08 '19 at 22:54

1 Answers1

0

Couple of things you can try:

1) Make sure you are using the same version of python as root and as the regular user. which python should work on a Unix based OS. Try that as root and compare to see if the python installations are the same.

2) Reinstall boost. Make sure it's the right version. Try using pip to do so.

3) If it's a permissions issue, you can change the permissions of the relevant directories with chown to ensure that the program can access it. This is NOT recommended. And I don't think this is the issue as the error is saying it cannot find libboost. Which means that there is some issue with the installation.

4) Install dlib from source. It's pretty easy. Check here for more information: http://dlib.net/compile.html. Essentially download the latest release and run python setup.py install from the main dlib folder. I can walk you through this if you need more help.

user3543300
  • 499
  • 2
  • 9
  • 27
  • i've tracked it down to the dlib.___file___ points to /usr/local/lib/python2.7/dist-packages/dlib.so when i import DLIB successfully as root. Is perhaps this path not working when i try to import it as a non privileged user? – Fight Fire With Fire Jan 08 '19 at 02:53
  • Unlikely, considering you can import other python libraries in the same directory without issue. Did you check and see if the python installation you ran as root is the same one? – user3543300 Jan 08 '19 at 05:09
  • yes it's the same one /usr/local/bin/python , its really weird. I can see that under root dlib imports and I can see the .so it's using, but the user account dlib is looking for a shared library that doesnt exist. – Fight Fire With Fire Jan 08 '19 at 21:23
  • Are you trying to run import dlib via a server like apache? – user3543300 Jan 08 '19 at 22:07