Closed dougalAgain closed 5 years ago
I got this error also once, but that was the issue that i used python 2 instead of 3. Could that also be an issue?
Second i see also import cv2 ImportError: No module named cv2
in your error message. That sounds to me that your python environment has cv2 not installed. Do you installed cv2 and if yes do you add it to a virtual environment?
Maybe the Config Parameter pythonPath
helps?
I checked this and I was indeed running python2 not 3 I've updated this but i still see the same error running: Python: 3.5.3 Python-Shell: 1.0.7
do i need to re-install anything else?
Where you have installed OpenCV? Do you installed this on a Virtual Python Environment?
Yes i installed in the virtual env when i run: `pi@raspberrypi:~ $ python Python 3.5.3 (default, Sep 27 2018, 17:25:39) [GCC 6.3.0 20170516] on linux Type "help", "copyright", "credits" or "license" for more information.
import cv2 Traceback (most recent call last): File "
", line 1, in ImportError: No module named 'cv2' `
But if i run: `pi@raspberrypi:~ $ workon cv (cv) pi@raspberrypi:~ $ python Python 3.5.3 (default, Sep 27 2018, 17:25:39) [GCC 6.3.0 20170516] on linux Type "help", "copyright", "credits" or "license" for more information.
import cv2 cv2.version '4.0.0' `
All is well
I have double checked the sym link
(cv) pi@raspberrypi:~/.virtualenvs/cv/lib/python3.5/site-packages $ ls -al total 8816 lrwxrwxrwx 1 pi pi 71 Sep 3 11:21 cv2.so -> /usr/local/python/cv2/python-3.5/cv2.cpython-35m-arm-linux-gnueabihf.so
and that looks fine (i recreated it)
I guess you do not run the MagicMirror within your "cv" Virtual Env? If i'm right, you need to tell my Module with the pythonPath
Property which python execution they should use. So you need to set pythonPath like this:
pythonPath: 'path/to/python'
In the Module-Settings of your MM.
AH HA! Thank you so much. Yes I needed to use: ~/.virtualenvs/cv/bin/python All fixed now!
Awesome if it works
When I run npm start i get the following:
Whoops! There was an uncaught exception... SyntaxError: Unexpected token T in JSON at position 0 at JSON.parse (<anonymous>) at PythonShell.asJson (/home/pi/MagicMirror/node_modules/python-shell/index.js:375:21) at /home/pi/MagicMirror/node_modules/python-shell/index.js:326:42 at Array.forEach (<anonymous>) at PythonShell.receiveInternal (/home/pi/MagicMirror/node_modules/python-shell/index.js:322:15) at PythonShell.receiveStderr (/home/pi/MagicMirror/node_modules/python-shell/index.js:306:21) at Socket.<anonymous> (/home/pi/MagicMirror/node_modules/python-shell/index.js:109:22) at Socket.emit (events.js:182:13) at addChunk (_stream_readable.js:279:12) at readableAddChunk (_stream_readable.js:260:13) MagicMirror will not quit, but it might be a good idea to check why this happened. Maybe no internet connection? If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues Whoops! There was an uncaught exception... { Error: ImportError: No module named 'cv2' at PythonShell.parseError (/home/pi/MagicMirror/node_modules/python-shell/index.js:260:21) at terminateIfNeeded (/home/pi/MagicMirror/node_modules/python-shell/index.js:139:32) at ChildProcess.<anonymous> (/home/pi/MagicMirror/node_modules/python-shell/index.js:131:13) at ChildProcess.emit (events.js:182:13) at Process.ChildProcess._handle.onexit (internal/child_process.js:237:12) ----- Python Traceback ----- File "modules/MMM-Face-Reco-DNN/tools/facerecognition.py", line 5, in <module> from stream import VideoStream File "/home/pi/MagicMirror/modules/MMM-Face-Reco-DNN/tools/stream.py", line 2, in <module> from webcam import WebcamVideoStream File "/home/pi/MagicMirror/modules/MMM-Face-Reco-DNN/tools/webcam.py", line 3, in <module> import cv2 traceback: 'Traceback (most recent call last):\n File "modules/MMM-Face-Reco-DNN/tools/facerecognition.py", line 5, in <module>\n from stream import VideoStream\n File "/home/pi/MagicMirror/modules/MMM-Face-Reco-DNN/tools/stream.py", line 2, in <module>\n from webcam import WebcamVideoStream\n File "/home/pi/MagicMirror/modules/MMM-Face-Reco-DNN/tools/webcam.py", line 3, in <module>\n import cv2\nImportError: No module named \'cv2\'\n', executable: 'python3', options: null, script: 'modules/MMM-Face-Reco-DNN/tools/facerecognition.py', args: [ '--cascade=modules/MMM-Face-Reco-DNN/tools/haarcascade_frontalface_default.xml', '--encodings=modules/MMM-Face-Reco-DNN/tools/encodings.pickle', '--usePiCamera=1', '--method=dnn', '--detectionMethod=hog', '--interval=2000', '--output=0' ], exitCode: 1 }
I tried updating the version of python-shell manually but this gives me another error:
PythonShell is not a constructor