TypeError: __init__() should return None, not 'NoneType' #49122

Closed
opened 2016-08-20 01:28:32 +02:00 by Pascal R. Jardin · 15 comments

hello,

I'm currently having trouble with appending a boost depended library called dlib.

all my libraries on my system are the same version of blender version 2.77a

this is my code:

import sys
pyodbcPath = ['/usr/local/lib/python3.5/site-packages', '/usr/local/lib/python3.5/site-packages/dlib-19.1.0-py3.5-macosx-10.11-x86_64.egg']
sys.path.extend(pyodbcPath)
import dlib
predictor_path = "/Users/pascaljardin/Desktop/shape_predictor_68_face_landmarks.dat"
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor(predictor_path)

this is where I receive the error

Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
TypeError: __init__() should return None, not 'NoneType'

I don't know why its giving this error, this should just work. i have spent a lot of time trying to figure out why I'm getting these errors. Maybe its a bug in blender or I'm having a brain fart and its one line of code to get this program running or maybe what I'm trying to do is impossible with blender... i don't know.

my project is using dlibs marker-less tracking system for facial recognition in which I can use to control characters in blender using any camera in real time.

to produce the same errors,

install python 3.5.1 onto your computer and install dlib for python 3.5.1
then append that to blender to integrate those libraries into blender.

cool tip:

also you can install opencv2 to python 3.5 and append that to blender to create a realtime augmented reality in which opencv tracks the head and moves the camera to create the illusion that any screen has 3d depth. I have successfully done this.

thank you for your time,

               Pascal
hello, I'm currently having trouble with appending a boost depended library called dlib. all my libraries on my system are the same version of blender version 2.77a this is my code: ``` import sys ``` ``` pyodbcPath = ['/usr/local/lib/python3.5/site-packages', '/usr/local/lib/python3.5/site-packages/dlib-19.1.0-py3.5-macosx-10.11-x86_64.egg'] ``` ``` sys.path.extend(pyodbcPath) ``` ``` import dlib ``` ``` predictor_path = "/Users/pascaljardin/Desktop/shape_predictor_68_face_landmarks.dat" ``` ``` detector = dlib.get_frontal_face_detector() ``` ``` predictor = dlib.shape_predictor(predictor_path) ``` this is where I receive the error ``` Traceback (most recent call last): File "<blender_console>", line 1, in <module> TypeError: __init__() should return None, not 'NoneType' ``` I don't know why its giving this error, this should just work. i have spent a lot of time trying to figure out why I'm getting these errors. Maybe its a bug in blender or I'm having a brain fart and its one line of code to get this program running or maybe what I'm trying to do is impossible with blender... i don't know. my project is using dlibs marker-less tracking system for facial recognition in which I can use to control characters in blender using any camera in real time. to produce the same errors, install python 3.5.1 onto your computer and install dlib for python 3.5.1 then append that to blender to integrate those libraries into blender. cool tip: also you can install opencv2 to python 3.5 and append that to blender to create a realtime augmented reality in which opencv tracks the head and moves the camera to create the illusion that any screen has 3d depth. I have successfully done this. thank you for your time, ``` Pascal

Changed status to: 'Open'

Changed status to: 'Open'

Added subscriber: @PascalJardin

Added subscriber: @PascalJardin

Added subscriber: @brecht

Added subscriber: @brecht

To be clear, you are getting this error when running the script from inside Blender, but not when running it from the command line with python3.5?

To be clear, you are getting this error when running the script from inside Blender, but not when running it from the command line with `python3.5`?

Added subscriber: @mont29

Added subscriber: @mont29

I really doubt Blender in itself has anything to do with this issue, this is purely low-level python issue, some init func (called by dlib.shape_predictor(predictor_path)?) returning None.__class__ instead of None from what you can guess from error message…

@brecht question is indeed first to answer. If your code works from regular python console, then it might be an issue between your system’s python and Blender’s python. To check that, you should try to build blender against your system python. Python version is not enough to ensure binary compatibility of (compiled) modules.

I really doubt Blender in itself has anything to do with this issue, this is purely low-level python issue, some init func (called by `dlib.shape_predictor(predictor_path)`?) returning `None.__class__` instead of `None` from what you can guess from error message… @brecht question is indeed first to answer. If your code works from regular python console, then it might be an issue between your system’s python and Blender’s python. To check that, you should try to build blender against your system python. Python version is not enough to ensure binary compatibility of (compiled) modules.

yes, I'm getting this error when I run the script in blender, but when I run it from the command line python 3.5 it works fine without any issues. And I have already tried to compile blender following the directions from the blender website.

 mkdir ~/blender-git
 cd ~/blender-git
 git clone http://git.blender.org/blender.git
 cd blender
 git submodule update --init --recursive
 git submodule foreach git checkout master
 git submodule foreach git pull --rebase origin master
 git pull --rebase
 git submodule foreach git pull --rebase origin master
sudo apt-get update; sudo apt-get install git build-essential
cd ~/blender-git
 ./blender/build_files/build_environment/install_deps.sh

compiling Blender using the steps above still produces an error. But the system python dose not generate an error

so, I'm I missing a step for it to use the system python3.5 instead of blender's or what I did above is correct?

if the steps above is not correct to build blender using the system python3.5, how do I build blender with my system python?

thank you for helping me with this

yes, I'm getting this error when I run the script in blender, but when I run it from the command line python 3.5 it works fine without any issues. And I have already tried to compile blender following the directions from the blender website. ``` mkdir ~/blender-git cd ~/blender-git git clone http://git.blender.org/blender.git cd blender git submodule update --init --recursive git submodule foreach git checkout master git submodule foreach git pull --rebase origin master ``` ``` git pull --rebase git submodule foreach git pull --rebase origin master ``` ``` sudo apt-get update; sudo apt-get install git build-essential ``` ``` cd ~/blender-git ./blender/build_files/build_environment/install_deps.sh ``` compiling Blender using the steps above still produces an error. But the system python dose not generate an error so, I'm I missing a step for it to use the system python3.5 instead of blender's or what I did above is correct? if the steps above is not correct to build blender using the system python3.5, how do I build blender with my system python? thank you for helping me with this

You may want to check that your /opt/lib/ folder has no python directory (that’s where install_deps puts its built libs, there’s no real reason for it to build python on any modern system, but there could be a left-over maybe…).

You can also try to disable all the WITH_PYTHON_INSTALL options of CMake config, those are useless on a linux system (and will save you a few Mb of disk space too).

Also! Looks like dlib uses boost::python to generate its pybinding code. So it could be some kind of conflict between Blender's boost and dlib's boost libraries maybe (not sure how exactly boost::python works, but knowing how boost loves nasty black magic tricks, would not be surprised generated pybinding still needs to link against some boost libs).

So could be worth checking you do not have any boost lib left over in /opt/lib either.

Besides that, googling your error I found this page, maybe can help you figure out what’s the exact issue?

You may want to check that your /opt/lib/ folder has no python directory (that’s where install_deps puts its built libs, there’s no real reason for it to build python on any modern system, but there could be a left-over maybe…). You can also try to disable all the `WITH_PYTHON_INSTALL` options of CMake config, those are useless on a linux system (and will save you a few Mb of disk space too). Also! Looks like dlib uses boost::python to generate its pybinding code. So it could be some kind of conflict between Blender's boost and dlib's boost libraries maybe (not sure how exactly boost::python works, but knowing how boost loves nasty black magic tricks, would not be surprised generated pybinding still needs to link against some boost libs). So could be worth checking you do not have any boost lib left over in /opt/lib either. Besides that, googling your error I found [this page](http://stackoverflow.com/questions/20437769/boost-python-init-should-return-none-not-nonetype), maybe can help you figure out what’s the exact issue?

from your helpful comment, I check the blender I compiled and it did not generate its own python. But it did seemed to generate its own boost. through some playing with compiling blender and going through the folders I believed I have narrowed down the problem to where dlib is not binding correctly to the blender boost like you said. This would explain how I can import dlib into blender with no problems, but when I use one of dibs advance functions it gives me an error. However I have no idea what pybindings I might need to link against to get the boost working. I'm going to contact the creator of dlib and see if he has any ideas on how to get this working.

and I went to the website link you sent me, it helped me by pointing me in the right direction in what I need to do, thank you.

and the /opt/lib/ folder on my computer is completely empty, I have a mac OS X if that matters at all.

from your helpful comment, I check the blender I compiled and it did not generate its own python. But it did seemed to generate its own boost. through some playing with compiling blender and going through the folders I believed I have narrowed down the problem to where dlib is not binding correctly to the blender boost like you said. This would explain how I can import dlib into blender with no problems, but when I use one of dibs advance functions it gives me an error. However I have no idea what pybindings I might need to link against to get the boost working. I'm going to contact the creator of dlib and see if he has any ideas on how to get this working. and I went to the website link you sent me, it helped me by pointing me in the right direction in what I need to do, thank you. and the /opt/lib/ folder on my computer is completely empty, I have a mac OS X if that matters at all.

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Bastien Montagne self-assigned this 2016-08-22 08:40:17 +02:00

Ah crap, I thought it was linux… Then it means you are using pre-compiled libs from svn repo to build Blender I guess?

What you should do in this case is to build both Blender and dlib with the same boost libraries (which means probably, build Blender with boost you used to build dlib, and not the one from svn libs, you'll have to change the paths for boost libs in Blender's CMake config).

In any case, thanks for the report, but this is definitively not a bug imho, so will close the report now.

Ah crap, I thought it was linux… Then it means you are using pre-compiled libs from svn repo to build Blender I guess? What you should do in this case is to build both Blender and dlib with the same boost libraries (which means probably, build Blender with boost you used to build dlib, and not the one from svn libs, you'll have to change the paths for boost libs in Blender's CMake config). In any case, thanks for the report, but this is definitively not a bug imho, so will close the report now.

well thank you for all your help! Now I know that all I need to do is to alter cmake for blender to use the boost I used to build dlib.

well thank you for all your help! Now I know that all I need to do is to alter cmake for blender to use the boost I used to build dlib.

...you don't have to answer this since this is not a bug, but it would be really helpful to me if you can. How do you change the paths for boost libs in Blender's CMake config?

thanks,

  Pascal
...you don't have to answer this since this is not a bug, but it would be really helpful to me if you can. How do you change the paths for boost libs in Blender's CMake config? thanks, ``` Pascal ```

Suggest you use cmake-gui (comes with cmake on Mac, afaik), open your build dir in it, and search for Boost entries (setting Boost_DIR to the base path of Blender's boost lib and re-running generate should be enough).

Suggest you use cmake-gui (comes with cmake on Mac, afaik), open your build dir in it, and search for Boost entries (setting Boost_DIR to the base path of Blender's boost lib and re-running generate should be enough).

installing dlib using blenders boost produced errors, but I was able to build blender using the boost dlib was built on. But I still get the

 TypeError: __init__() should return None, not 'NoneType'

I don't know what to do

for my project I need a facial landmark detector that can be intergraded into blender. By any chance, do you know if there is a library that detects facial expressions and is compatible to blender that I can use instead? Because if there is another library out there that can be easily integrated with blender that detects facial landmarks that would be amazing! :)

thanks
Pascal

installing dlib using blenders boost produced errors, but I was able to build blender using the boost dlib was built on. But I still get the ``` TypeError: __init__() should return None, not 'NoneType' ``` I don't know what to do for my project I need a facial landmark detector that can be intergraded into blender. By any chance, do you know if there is a library that detects facial expressions and is compatible to blender that I can use instead? Because if there is another library out there that can be easily integrated with blender that detects facial landmarks that would be amazing! :) thanks Pascal
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#49122
No description provided.