Python 3.4搭配Dlib调用dlib.get_face_chip()时遇AttributeError求助
AttributeError with dlib.get_face_chip() in Python 3.4 Hey there, let's work through this AttributeError you're hitting with dlib.get_face_chip()—I've dealt with similar issues before, so here are the most likely fixes to try:
1. Your Dlib version is too old
The get_face_chip() method was added in Dlib 19.7, so if you're running an older version, this method won't exist. Since you're on Python 3.4 (which is end-of-life, but I get sticking with it for legacy projects), you'll need a Dlib release that supports both Python 3.4 and includes this method.
First, check your current Dlib version:
import dlib print(dlib.__version__)
If it's older than 19.7, upgrade to a compatible version. 19.8.1 is one of the last releases that works with Python 3.4—install it with:
pip install dlib==19.8.1
2. You've got a naming conflict
It sounds silly, but it's super common: if you've named your own script dlib.py, Python will import your local file instead of the actual Dlib library. Check your project directory for any files named dlib.py and rename them to something else (like my_dlib_utils.py).
Also, double-check your import statement is straightforward:
import dlib
Avoid any aliases or partial imports that might hide the method.
3. Typo in the method name
Double-check you're spelling the method correctly! It's dlib.get_face_chip() (singular "chip"), not get_face_chips() or any variation with typos. Even a tiny mistake here will trigger an AttributeError.
4. Broken Dlib installation
Sometimes a botched install can leave out parts of the Python bindings. Try reinstalling Dlib completely:
pip uninstall -y dlib
Before reinstalling, make sure you have all required build dependencies installed (CMake, Boost, and a C++ compiler). For Python 3.4, you might need older versions of these tools, so refer to the Dlib docs for the version you're installing to get the right setup steps.
Give these steps a try—one of them should resolve the issue!
内容的提问来源于stack exchange,提问作者decadenza

