install KIVY for python - kivy

I have an error when I run this:
pip install kivy
Here is the error:
Collecting kivy
Using cached Kivy-1.10.0.tar.gz
Complete output from command python setup.py egg_info:
Using distutils
Cython is missing, it's required for compiling kivy !
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-aHd9E8/kivy/setup.py", line 219, in <module>
from Cython.Distutils import build_ext
ImportError: No module named Cython.Distutils
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-aHd9E8/kivy/
So could someone help me to install this python library (for python 2.7 if possible) please, I made my researches and I did not find anything.

Install these:
brew install pkg-config sdl2 sdl2_image sdl2_ttf sdl2_mixer gstreamer
xcode-select --install
pip install Cython==0.26.1 --user
pip install https://github.com/kivy/kivy/archive/master.zip
You should be able to use kivy on MacOSX high sierra
theecodedragon$ python
Python 2.7.10 (default, Jul 15 2017, 17:16:57)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import kivy
[WARNING] [Config ] Older configuration version detected (0 instead of 20)
[WARNING] [Config ] Upgrading configuration in progress.
[INFO ] [Logger ] Record log in /Users/theecodedragon/.kivy/logs/kivy_17-11-09_0.txt
[INFO ] [Kivy ] v1.10.1.dev0, git-Unknown, 20171108
[INFO ] [Python ] v2.7.10 (default, Jul 15 2017, 17:16:57)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)]
>>>
Edit:
This works with latest version as of now:
theecodedragon$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.13.1
BuildVersion: 17B48

Try installing Cython:
pip install Cython.
If it doesn't help, you may be using the wrong python installation. Refer to this answer for details.

Related

How to set up Raspberry Pi Buster and Intel NCS2 and OpenVINO with OpenCV trackers

Is there a definitive set of instructions to implement OpenCV trackers with OpenVINO and the now-obsolete NCS2 on a RPi 4b - Buster?
My understanding that the last OpenVINO to support the NCS2 was v2020.3.
I attempted to cross-compile using:
https://github.com/opencv/opencv/wiki/Intel-OpenVINO-backend#raspbian-buster
After installing opencv/opencv-contrib 4.5.5 from source:
$ python3
Python 3.7.3 (default, Oct 31 2022, 14:04:00)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'4.5.5'
>>> tracker = cv2.TrackerCSRT_create()
>>>
However, in a test.py script I have:
...
import cv2
net = cv2.dnn.readNetFromCaffe(_weights, _model)
net.setPreferableTarget(cv2.dnn.DNN_TARGET_MYRIAD)
...
detections = net.forward()
I get the error relating to DNN_TARGET_MYRIAD:
cv2.error: OpenCV(4.5.5) /home/pi/opencv/modules/dnn/src/dnn.cpp:1414: error: (-215:Assertion failed) preferableBackend != DNN_BACKEND_OPENCV || preferableTarget == DNN_TARGET_CPU || preferableTarget == DNN_TARGET_OPENCL || preferableTarget == DNN_TARGET_OPENCL_FP16 in function 'setUpNet'
I then used this to install OpenVINO:
https://docs.openvino.ai/latest/openvino_docs_install_guides_installing_openvino_raspbian.html
but using this version of OpenVINO (as the last to support the NCS2):
https://storage.openvinotoolkit.org/repositories/openvino/packages/2020.3/l_openvino_toolkit_runtime...
I exported the paths to the new post cross-compiled opencv_install directory:
$ export PYTHONPATH=/home/pi/Desktop/opencv_install/lib/python2.7/dist-packages/:$PYTHONPATH
$ export PYTHONPATH=/home/pi/Desktop/opencv_install/lib/python3.7/site-packages/:$PYTHONPATH
$ export LD_LIBRARY_PATH=/home/pi/Desktop/opencv_install/lib/:$LD_LIBRARY_PATH
I set up the NCS2 with no errors :
$ sudo usermod -a -G users "$(whoami)"
$ sh /opt/intel/openvino_2020.3/install_dependencies/install_NCS_udev_rules.sh
then:
$ source /opt/intel/openvino_2020.3/bin/setupvars.sh
and then checked:
$ python3
Python 3.7.3 (default, Oct 31 2022, 14:04:00)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'4.3.0-openvino-2020.3.0'
>>> tracker = cv2.TrackerCSRT_create()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'cv2' has no attribute 'TrackerCSRT_create'
>>>
If I open a new terminal and $ source /opt/intel/openvino_2020.3/bin/setupvars.sh
then run a test.py script:
...
import cv2
net = cv2.dnn.readNetFromCaffe(_weights, _model)
net.setPreferableTarget(cv2.dnn.DNN_TARGET_MYRIAD)
...
detections = net.forward()
...
I get a segmentation fault error.
So far I have not edited any of the setup scripts.
Thanks for any help! I'd like to put this NCS2 to work.
Generally, if you are able to run some OpenVINO demo with NCS2 after following this installation guide, then you should be able to use that OpenCV functionality (ensured that you had installed the correct OpenCV).
It's recommended to use the recent OpenVINO and OpenCV version.
As indicated in this OpenVINO System Requirements, the current recommended OpenCV version is 4.5.

conda python 3.7 opencv import error libgnutls.so.30: undefined symbol: mpn_add_1, version HOGWEED_4

I am facing problem while getting opencv to work with python 3.7 in Conda on Ubuntu 20.04.
I get the following error when I try to import cv2 in python:
$ python
Python 3.7.8 | packaged by conda-forge | (default, Jul 23 2020, 03:54:19)
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /home/swagat/anaconda3/envs/tf2py37/lib/python3.7/site-packages/../../././libgnutls.so.30: undefined symbol: mpn_add_1, version HOGWEED_4
my Conda configuration looks something like this:
active environment : tf2py37
active env location : /home/swagat/anaconda3/envs/tf2py37
shell level : 2
user config file : /home/swagat/.condarc
populated config files :
conda version : 4.8.5
conda-build version : 3.18.9
python version : 3.7.4.final.0
virtual packages : __cuda=10.1
__glibc=2.31
I installed opencv from the conda-forge channel using the following command:
$ conda install -c conda-forge opencv
I can see that opencv is installed on my system:
$ conda list opencv
# packages in environment at /home/swagat/anaconda3/envs/tf2py37:
#
# Name Version Build Channel
libopencv 4.5.0 py37_2 conda-forge
opencv 4.5.0 py37_2 conda-forge
py-opencv 4.5.0 py37hc6149b9_2 conda-forge
I also checked if gnutls is installed:
$ conda list gnutls
# packages in environment at /home/swagat/anaconda3/envs/tf2py37:
#
# Name Version Build Channel
gnutls 3.6.13 h79a8f9a_0 conda-forge
What else I can try to solve this problem? I am kind of stuck here. Any help will be appreciated. Thanks.
It seems that conda version of the opencv is broken.
My solution is:
remove your conda opencv and install the native one:
conda remove opencv
python -m pip install opencv-python # Execute this with your conda env activated

Still loads previous version after upgrading latest version OpenCV 4.4.0

I upgraded OpenCV 4.4.0 from OpenCV 4.2.x with pip command :
pip install --upgrade opencv-python==4.4.0.40
and checked the upgrade completed :
Collecting opencv-python==4.4.0.40
|████████████████████████████████| 33.5 MB 283 kB/s
Requirement already satisfied, skipping upgrade: numpy>=1.17.3 in c:\users\kangs\anaconda3\lib\site-packages (from opencv-python==4.4.0.40) (1.18.5)
Found existing installation: opencv-python 4.3.0.36
Successfully uninstalled opencv-python-4.3.0.36
PS C:\Users\kangs\Documents\TELPA\Source\numberplateRecognition> python
Python 3.8.3 (default, Jul 2 2020, 17:30:36) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'4.4.0'
>>> exit()
However, I still get this error message when I run this code :
cv2.dnn.readNet(WEIGHTS, CFG)
Error message :
Traceback (most recent call last):
File "c:\Users\kangs\Documents\TELPA\Source\numberplateRecognition\number_plate_v4c.py", line 54, in <module>
File "c:\Users\kangs\Documents\TELPA\Source\numberplateRecognition\algorithm\detection\yolodetector.py", line 39, in __init__
self.load_dir(dir_path)
File "c:\Users\kangs\Documents\TELPA\Source\numberplateRecognition\algorithm\detection\yolodetector.py", line 50, in load_dir
self.load_files(file_list)
File "c:\Users\kangs\Documents\TELPA\Source\numberplateRecognition\algorithm\detection\yolodetector.py", line 78, in load_files
self.net = cv2.dnn.readNet(WEIGHTS, CFG)
cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\dnn\src\darknet\darknet_io.cpp:686: error: (-212:Parsing error) Unsupported activation: mish in function 'cv::dnn::darknet::ReadDarknetFromCfgStream'
I found out that the code still linked to the previous library OpenCV 4.2.0.
Can someone please let me know why this happens and how to solve this problem?

Issue installing OpenCV 4.1.2 on Jetson Nano. import cv2, No module named 'cv2'

I installed OpenCV 4.1.2 from source with CUDA support. Had no issues. and created a symbolic link from OpenCV’s installation directory to my virtualenv
ln -s /usr/local/lib/python3.6/site-packages/cv2/python3.6/cv2.cpython-36m-aarch64-linux-gnu.so cv2.so
I am having an issue with import cv2
$ python
Python 3.6.9 (default, Nov 7 2019, 10:44:02)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cv2'
>>>
I checked site-packages directory and I can see cv2.so. I am obviously missing something.
The main issue here in my view I am not able to link to my virtualenv, in fact I am able to check my installation and its working
/usr/local/lib/python3.6/site-packages/cv2/python-3.6$ python
Python 3.6.9 (default, Nov 7 2019, 10:44:02)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>>
Issue solved a very very little mistake
I changed the name from
cv2.cpython-36m-aarch64-linux-gnu.so to cv2.so
I realized it was an issue with one of the folders, this will do the magic:
ln -s /usr/local/lib/python3.6/site-packages/cv2/python-3.6/cv2.so cv2.so
notice its python-3.6 not python3.6 after cv2

Ubuntu: downgrade SDL2 version

I'm trying to run a python graphical application made with KIVY framework, then I have this on my terminal:
root#MZs83nQ1:/home/kruqer/Documents/mybackup/Appoff# python appoff.py
[INFO ] [Logger ] Record log in /root/.kivy/logs/kivy_17-11-09_5.txt
[INFO ] [Kivy ] v1.10.0
[INFO ] [Python ] v2.7.14 (default, Sep 23 2017, 22:06:14)
[GCC 7.2.0]
Traceback (most recent call last):
File "appoff.py", line 2, in <module>
from kivy.app import App
File "/usr/lib/python2.7/dist-packages/kivy/app.py", line 319, in <module>
from kivy.base import runTouchApp, stopTouchApp
File "/usr/lib/python2.7/dist-packages/kivy/base.py", line 30, in <module>
from kivy.event import EventDispatcher
File "/usr/lib/python2.7/dist-packages/kivy/event.py", line 8, in <module>
import kivy._event
ImportError: /usr/lib/python2.7/dist-packages/kivy/_event.x86_64-linux-gnu.so: undefined symbol: PyFPE_jbuf
I made researches on google and I found this topic and I need to downgrade my sdl2 version to a version between 2.0.5 and 2.0.6, but I can't see which version am I running actually and don't know how to downgrade it.
My OS is Ubuntu 17.10.
Display SDL Version
Execute the following and it will show you the SDL version that you are using:
dpkg -l | grep sdl
Uninstall
sudo apt-get remove package1 [package2 ...]
Install
Python 2.x/3.x
sudo apt-get install -y \
libsdl2-dev \
libsdl2-image-dev \
libsdl2-mixer-dev \
libsdl2-ttf-dev
Example - OS: Ubuntu 16.04 LTS (64bits), Python 2.x

Resources