In import dlib, zsh:segmentation fault python appears.

Asked 2 years ago, Updated 2 years ago, 19 views

python 2.7.10
Use pyenv


python
Python 2.7.10 (default, May 7 2016, 10:54:58)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>import dlib
zsh —segmentation fault python

It will be...

Running python with dlib


importos
import sys
import glob
import dlib
from image importio

import dlib in


Traceback (most recent call last):
  File "./gen_detector.py", line 7, in 
    import dlib
ImportError: No module named dlib

It will be...

I thought it was probably because there was no path in the dlib, but if you look at zshrc,


exportPYENV_ROOT=$HOME/.pyenv
export PATH=$PYENV_ROOT/bin:$PATH

export PYTHONPATH=/usr/local/lib/python 2.7/site-packages: $PYTHONPATH

I thought there was no problem with the path since I wrote import numpy and so on.

I am quite into it, so I would appreciate it if you could tell me how to solve it.
Thank you for your cooperation!

python

2022-09-30 19:56

1 Answers

1.pyenvinit

Is the result of which python /Users/YYYYY/.pyenv/shims/python?If /usr/bin/python, python in pyenv is not used.
if which pyenv>/dev/null;the event "$(pyenv init-)";fi
Please confirm that you have added to .bash_profile.
This ensures that $PATH contains through/.pyenv/shims, which allows proper use of python and pip.
If you did not do this, the library may be installed on the system, not under .pyenv.

Note: https://github.com/yyuu/pyenv#advanced-configuration

2.PYTHONPATH Configuration

Since you are using pyenv, I think the libraries you need are installed in ~/.pyenv/versions/XXXXXX/lib/.
If you configure PYTHONPATH, you will prefer to load the libraries in the system instead of the libraries installed in pyenv.

%python
Python 3.5.1 | Anaconda custom (x86_64) | (default, Dec 7 2015, 11:24:55)
GCC 4.2.1 (Apple Inc. build 5577) on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>import sys
>>print(sys.path)
[', '/Users/YYYYYYY/.pyenv/versions/XXXXX/lib/python35.zip', '/Users/YYYYYYYY/.pyenv/versions/XXXXX/lib/python3.5',...

If sys.path is appropriate, you do not need to configure PYTHONPATH.

Therefore, remove the PYTHONPATH setting → Add pyenv init to the configuration file → Restart the shell to see if the version you want to use (instead of system) is set properly → Install the library with pip install Please check again.


2022-09-30 19:56

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.