I am trying to execute a python code using a kinect
this is 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
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:
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.
You can find where it was installed by:
find /usr/local/lib -iname freenect.so
Hope it helps anybody.
Install:
libfreenect
Try:
sudo 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
This worked for me on Ubuntu 14.04 LTS
Related
I am integrating gstreamer and pocketsphinx on mac using python 3.6; however, the first line of code, from gi import pygtkcompat, raises an error.
The command:
python3 demoapp_chinese.py
returns
Traceback (most recent call last):
File "demoapp_chinese.py", line 1, in
from gi import pygtkcompat
ModuleNotFoundError: No module named 'gi'
Here's how I install pygobject:
brew install pygobject3
And when I try to get more info. I execute
brew info pygobject3
which returns
pygobject3: stable 3.30.4 (bottled)
GNOME Python bindings (based on GObject Introspection)
https://wiki.gnome.org/Projects/PyGObject
/usr/local/Cellar/pygobject3/3.30.4 (69 files, 1.6MB) *
Poured from bottle on 2019-02-04 at 17:21:21
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/pygobject3.rb
(here I only post the first few couple of lines)
For the python info,
which python3
returns
/usr/local/bin/python3
Besides,
echo $PYTHONPATH
returns
/usr/local/lib/python3.6/site-packages
echo $PATH
returns
/Users/cindy/bin:/usr/local/bin/python3.6:/usr/local/lib/python3.6/site-packages:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public
Lastly, I don't know if this is normal, when I run
which pygobject3
NOTHING returns on the terminal.
Please help, thanks. If you need any extra info. to help me, please let me know.
I use this tutorial text as an example, there are others:
#!/usr/bin/python
import MySQLdb
If it produces the following result, then it means MySQLdb module is not installed −
Traceback (most recent call last):
File "test.py", line 3, in <module>
import MySQLdb
ImportError: No module named MySQLdb
To install MySQLdb module, use the following command −
For Ubuntu, use the following command -
$ sudo apt-get install python-pip python-dev libmysqlclient-dev
I have gone trough these steps, more or less as described above.
Problem is that the subdirectory "python" does not exist under /usr/bin/
in my file system. I run Linux Mint 18.3. Python 2.7 seems to be the native version installed in Mint (used for several purposes), but I have also installed Python 3.6.4 and wish to use this for development purposes.
Does anyone know in which directory I could expect to find MySQLdb?
Since #!/usr/bin/python is non existent I wonder - has MySQLdb been properly installed? If it has, I have not after several efforts succeded in locating it.
I wish if anyone could give me a hand with my prob,
I have installed python 3.6 amd64 and add it to path then installed opencv 3.2 successfully using "pip" ... However, when I'm trying to import the cv2 (the library of opencv) and here is the error that I have got:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import cv2
ImportError: DLL load failed: The module specified is not found.
Make sure that cv2.pyd is in your Python's lib\site-packages\ directory.
Also check if OPENCV_DIR = C:\Program Files\OpenCV 3.2.0\x64\vc14, or similar, is in your Windows' system variables setting. The sample path OPENCV_DIR is for the binary compiled with VC14 which is Visual Studio 2015 VC++.
I'm guessing you've installed pip2(for python2) instead of pip3.(for python3)
Try this to install pip for python3
sudo apt-get install python3-pip
Now use
pip3 install python3-opencv
Here is a post about installing a module in python3. When I use brew install python, then it installs it for 2.7.
When I use the method suggested by dan, which aimed to install it directly in python3 (who i really thank), but which didn't work :
# Figure out the path to python3
PY3DIR=`dirname $(which python3)`
# And /then/ install with brew. That will have it use python3 to get its path
PATH=$PY3DIR:$PATH brew install mapnik
The installation was successful but in python2. so I get:
For non-homebrew Python, you need to amend your PYTHONPATH like so: export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH
so i finally add the path manually in python3 :
import sys
sys.path.append('/usr/local/lib/python2.7/site-packages')
I get this error :
Traceback (most recent call last): File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/mapnik/__init__.py", line 69, in <module>
from _mapnik import * ImportError: dlopen(./_mapnik.so, 2): Symbol not found: _PyClass_Type Referenced from: ./_mapnik.so
Expected in: flat namespace in ./_mapnik.so
Please help, I have spent so many hours on this ...
Thanks!!!
The Mapnik python bindings depend on boost_python. And both need to use the same python. The problem is likely that homebrew is providing a bottle of boost which includes boost python built against python 2.7 and not python 3.x.
I am on Mac OS X and I would like to use a python script like this one to manipulate an OTF with fontforge. The problem is, how do I access fontforge? Do I need a special build for that?
This is what I get when I run the file
Traceback (most recent call last):
File "myfile.py", line 6, in <module>
import fontforge
ImportError: No module named fontforge
(line 6 is import fontforge)
first uninstall what you currently have installed:
port uninstall fontforge
then install the python variant:
port install fontforge +python27
there's also a python26 variant. to see all variants port variants fontforge
You can get the FontForge development version's python module with HomeBrew:
$ brew install python
$ brew install fontforge --HEAD