Open MattTucker22689 opened 7 years ago
If you install python via brew, it should just work. Otherwise, add the brew directory to PYTHONPATH
.
If I use "brew link --overwrite python" will I need to worry about not being able to use Numpy, OpenCV, or anything of the sort? And could that fix the problem?
Also, I'm not 100% clear on what to do with "export PYTHONPATH=brew --prefix
/lib/python2.7/site-packages:$PYTHONPATH." When I entered back into "~/.bash_profile" via ''nano", I saw NO changes? What am I not catching?
Thoughts? Further clarification...?
(I'm assuming python2) If you type this in the terminal
export PYTHONPATH=`brew --prefix`/lib/python2.7/site-packages:$PYTHONPATH
echo $PYTHONPATH
you should see that the brew directory has been added to PYTHONPATH
. In another window, go to that site-packages directory and confirm there's a freenect module there. Then
idle
>>> import freenect
If that doesn't work, I'll have to track down a Mac and try it myself.
So, I went back and tried it again... Here is everything straight from terminal:
So, I've done some more digging... Still no dice... But there's this:
So I know it downloaded. But that's literally where it stops... Because nothing wants to work
So, I just downloaded X11, and can now run freenect-glview from terminal.... but still can't import freenect in Python. Also, yes I'm using Python 2.7.
D'oh, I didn't realize that the Formula doesn't build any python bits. This manual way worked for me.
brew install cython
git clone https://github.com/OpenKinect/libfreenect
cd libfreenect
mkdir build
cd build
cmake .. -DBUILD_PYTHON2=ON -DCYTHON_EXECUTABLE="/usr/local/opt/cython/bin/cython"
make
cd wrappers/python/python2
python
>>> import freenect
The permanent solution will be to patch the Formula to take an optional dependency on python and cython.
SOLID! IT WORKS NOW!
Thank you so very much for your help!
So how does one "patch the Formula to take an optional dependency on python and cython" for the permanent fix?
I'm trying to do that at homebrew-core#16772, but there are some remaining issues with the build process.
@piedar Hi piedar,
Do you happen to have a solution for python 3.7?
I pretty much followed the instructions on the readme and I'm stuck on the step where i type python setup.py install
in the libfreenect/wrappers/python
directory. I have no where else to look for help...
This is my output:
running install
running build
running build_ext
skipping 'freenect.c' Cython extension (up-to-date)
building 'freenect' extension
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/eyun89/anaconda3/include -arch x86_64 -I/Users/eyun89/anaconda3/include -arch x86_64 -I/Users/eyun89/anaconda3/include/python3.7m -c freenect.c -o build/temp.macosx-10.7-x86_64-3.7/freenect.o -fPIC -I ../../include/ -I /usr/include/libusb-1.0/ -I /usr/local/include/libusb-1.0 -I /usr/local/include -I ../c_sync/ -I /Users/eyun89/anaconda3/lib/python3.7/site-packages/numpy/core/include
In file included from /Users/eyun89/anaconda3/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1823:0,
from /Users/eyun89/anaconda3/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:18,
from /Users/eyun89/anaconda3/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
from freenect.c:353:
/Users/eyun89/anaconda3/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
#warning "Using deprecated NumPy API, disable it by " \
^
In file included from freenect.c:355:0:
../../include/libfreenect.h:567:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
FREENECTAPI int freenect_get_video_mode_count();
^
../../include/libfreenect.h:619:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
FREENECTAPI int freenect_get_depth_mode_count();
^
freenect.c: In function ‘__Pyx_ExceptionSave’:
freenect.c:11588:19: error: ‘PyThreadState’ has no member named ‘exc_type’
*type = tstate->exc_type;
^
freenect.c:11589:20: error: ‘PyThreadState’ has no member named ‘exc_value’
*value = tstate->exc_value;
^
freenect.c:11590:17: error: ‘PyThreadState’ has no member named ‘exc_traceback’
*tb = tstate->exc_traceback;
^
freenect.c: In function ‘__Pyx_ExceptionReset’:
freenect.c:11602:22: error: ‘PyThreadState’ has no member named ‘exc_type’
tmp_type = tstate->exc_type;
^
freenect.c:11603:23: error: ‘PyThreadState’ has no member named ‘exc_value’
tmp_value = tstate->exc_value;
^
freenect.c:11604:20: error: ‘PyThreadState’ has no member named ‘exc_traceback’
tmp_tb = tstate->exc_traceback;
^
freenect.c:11605:11: error: ‘PyThreadState’ has no member named ‘exc_type’
tstate->exc_type = type;
^
freenect.c:11606:11: error: ‘PyThreadState’ has no member named ‘exc_value’
tstate->exc_value = value;
^
freenect.c:11607:11: error: ‘PyThreadState’ has no member named ‘exc_traceback’
tstate->exc_traceback = tb;
^
error: command 'gcc' failed with exit status 1
Thanks in advanced for your time.
Experiencing the same behavior as @eyun89 with a slightly different message:
python setup.py install
running install
running build
running build_ext
skipping 'freenect.c' Cython extension (up-to-date)
building 'freenect' extension
gcc -pthread -B /home/ren/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/ren/anaconda3/include/python3.7m -c freenect.c -o build/temp.linux-x86_64-3.7/freenect.o -fPIC -I ../../include/ -I /usr/include/libusb-1.0/ -I /usr/local/include/libusb-1.0 -I /usr/local/include -I ../c_sync/ -I /home/ren/anaconda3/lib/python3.7/site-packages/numpy/core/include
In file included from /home/ren/anaconda3/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1822:0,
from /home/ren/anaconda3/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
from /home/ren/anaconda3/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
from freenect.c:353:
/home/ren/anaconda3/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
#warning "Using deprecated NumPy API, disable it with " \
^~~~~~~
In file included from freenect.c:355:0:
../../include/libfreenect.h:567:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
FREENECTAPI int freenect_get_video_mode_count();
^~~~~~~~~~~
../../include/libfreenect.h:619:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
FREENECTAPI int freenect_get_depth_mode_count();
^~~~~~~~~~~
freenect.c: In function ‘__Pyx_ExceptionSave’:
freenect.c:11588:21: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_type’; did you mean ‘curexc_type’?
*type = tstate->exc_type;
^~~~~~~~
curexc_type
freenect.c:11589:22: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_value’; did you mean ‘curexc_value’?
*value = tstate->exc_value;
^~~~~~~~~
curexc_value
freenect.c:11590:19: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
*tb = tstate->exc_traceback;
^~~~~~~~~~~~~
curexc_traceback
freenect.c: In function ‘__Pyx_ExceptionReset’:
freenect.c:11602:24: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_type’; did you mean ‘curexc_type’?
tmp_type = tstate->exc_type;
^~~~~~~~
curexc_type
freenect.c:11603:25: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_value’; did you mean ‘curexc_value’?
tmp_value = tstate->exc_value;
^~~~~~~~~
curexc_value
freenect.c:11604:22: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
tmp_tb = tstate->exc_traceback;
^~~~~~~~~~~~~
curexc_traceback
freenect.c:11605:13: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_type’; did you mean ‘curexc_type’?
tstate->exc_type = type;
^~~~~~~~
curexc_type
freenect.c:11606:13: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_value’; did you mean ‘curexc_value’?
tstate->exc_value = value;
^~~~~~~~~
curexc_value
freenect.c:11607:13: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
tstate->exc_traceback = tb;
^~~~~~~~~~~~~
curexc_traceback
error: command 'gcc' failed with exit status 1
Hmm, maybe you need a newer version of cython?
@piedar Perfect! That did it
Any idea how to fix this when using virtualenv? Openfreenect compiles fine--I can view the C++ demos just fine. And I also have the latest Cython in my virtualenv.
Okay, I think I fixed the issue. I had to follow the errors and go into freenect.c and change each call to exc_value, exc_traceback, exc_type -> curexc_value, curexc_traceback, curexc_type.
Great! I have the same error. I will try it
D'oh, I didn't realize that the Formula doesn't build any python bits. This manual way worked for me.
brew install cython git clone https://github.com/OpenKinect/libfreenect cd libfreenect mkdir build cd build cmake .. -DBUILD_PYTHON2=ON -DCYTHON_EXECUTABLE="/usr/local/opt/cython/bin/cython" make cd wrappers/python/python2 python >>> import freenect
The permanent solution will be to patch the Formula to take an optional dependency on python and cython.
I did the same but still after running python3 -c'import freenect' I have ModuleNotFoundError: No module named 'freenect'. I feel hopeless also I am beginner so many things are new for me.
macOS Ventura 13.1 Python 3.8
Can someone give me a hand here?
Installing libfreenect using homebrew work fine for me using:
brew install libfreenect
but apparently, it comes with no wrappers?
Trying to import freenect
from python does not work as well...
Running /opt/homebrew/Cellar/libfreenect/0.6.4/bin/freenect-glview
works fine for me.
Where do I go from here for importing the lib in python?
D'oh, I didn't realize that the Formula doesn't build any python bits. This manual way worked for me.
brew install cython git clone https://github.com/OpenKinect/libfreenect cd libfreenect mkdir build cd build cmake .. -DBUILD_PYTHON2=ON -DCYTHON_EXECUTABLE="/usr/local/opt/cython/bin/cython" make cd wrappers/python/python2 python >>> import freenect
The permanent solution will be to patch the Formula to take an optional dependency on python and cython.
I tried this (-DCYTHON_EXECUTABLE=/opt/homebrew/Cellar/cython/0.29.33/bin/cython worked for me) but then I got the following error:
@matheusft I suggest you try the steps mentioned as well and see what happens.
Ok, so I ran thru "brew install libfreenect, " as instructed in the ReadMe. But when I go to import it, IDLE keeps giving me this message:
"Traceback (most recent call last): File "<pyshell#0>", line 1, in
import freenect
ModuleNotFoundError: No module named 'freenect'"
I'm running OSX Sierra. Help?