简体   繁体   English

NameError:名称“ freenect”未定义

[英]NameError: name 'freenect' is not defined

I am trying to execute a python code using a kinect this is awesome.py: 我正在尝试使用kinect执行python代码,这是awesome.py:

from SimpleCV import * 
import freenect

cam = Kinect()
depth = cam.getDepth()
depth.show()

and I'm getting this error: 我收到此错误:

Traceback (most recent call last):
  File "awesome.py", line 2, in <module>
    import freenect
ImportError: No module named freenect
libusb: 0.460928 debug [libusb_exit] 
libusb: 0.461054 debug [usbi_remove_pollfd] remove fd 6
libusb: 0.461203 debug [usbi_remove_pollfd] remove fd 9

Install: 安装:

libfreenect libfreenect

Try: 尝试:

sudo python2 libfreenect/wrappers/python/demo_cv_async.py 须藤python2 libfreenect / wrappers / python / demo_cv_async.py

Install python-freenect and other necessary modules by first : apt-cache search freenect And then you can select all libfreenect packages as per your convenience: for this python code error: sudo apt-get install python-freenect 首先安装python-freenect和其他必要的模块:apt-cache search freenect然后您可以根据需要选择所有libfreenect软件包:对于此python代码错误:sudo apt-get install python-freenect

This worked for me on Ubuntu 14.04 LTS 这在Ubuntu 14.04 LTS上为我工作

This solved it for me. 这为我解决了。 Note that you need to check if the names of your directories match mine. 请注意,您需要检查目录名称是否与我的目录匹配。 It depends on the Python versions you have installed: 这取决于您安装的Python版本:

sudo ln -s /usr/local/lib/python3/dist-packages/freenect.so /usr/local/lib/python3.7/dist-packages/.

That freenect.so was installed by default on Python3, so I've linked to it from Python3.7, which is the default for my system. 该freenect.so默认安装在Python3上,因此我已从Python3.7链接到它,这是系统的默认设置。 You can find where it was installed by: 您可以通过以下方式找到它的安装位置:

 find /usr/local/lib -iname freenect.so

Hope it helps anybody. 希望它能对任何人有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM