I'm trying to run cv2 in Deepnote, but when I do it I get the following error:
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
I have proved the following:
!pip install ffmpeg libsm6 libxext6
!pip install libgl1-mesa-dev
But when I run it, I have this error:
Could not find a version that satisfies the requirement...
No matching distribution found for...
Does anyone know how to import cv2 in Deepnote, can you help me!
Thanks!
It is because ffmpeg libsm6 libxext6 libgl1-mesa-dev are linux packages and you are trying to install them as if they were python packages. You need to install them to your operating system instead of python environment.
you can install them by using
!apt install ffmpeg libsm6 libxext6 libgl1-mesa-dev
instead.
Here you can see an example of how to do it.
Related
There are many steps while installing OpenCV on Raspberry pi . Is there any chance to install by using a single command. I tried sudo apt-get install python3-opencv but that doesn't work.
The main one liner is with pip The Python Package Installer but to make it work you also need some dependencies that may or may not be installed already from other related tools.
$ pip3 install opencv-python
$ sudo apt-get install libatlas-base-dev libjasper-dev libqtgui4 python3-pyqt5 libqt4-test libilmbase-dev libopenexr-dev libgstreamer1.0-dev libavcodec58 libavformat58 libswscale5
In addition with the current newest version you need to set an env variable to run it, LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libatomic.so.1.2.0 referenced issue
$ LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libatomic.so.1.2.0 python3
Python 3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>>
If you are really opposed to that you can use a previous version that doesn't have this issue. Don't forget to uninstall the other version if you already installed it pip3 uninstall opencv-python
$ pip3 install opencv-python==4.1.0.25
On a newly flashed 2019-09-26-raspbian-buster-lite img after adding ssh access and connecting that way.
system update and install pip3
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install python3-pip
version check
$ python3 --version
Python 3.7.3
$ pip3 --version
pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)
install openCV and check version
$ pip3 install opencv-python
$ pip3 freeze | grep opencv-python
opencv-python==4.1.1.26
test and fail,
$ python3
Python 3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.2.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>
File "/home/pi/.local/lib/python3.7/site-packages/cv2/__init__.py", line 3, in <module>
from .cv2 import *
ImportError: libwebp.so.6: cannot open shared object file: No such file or directory
install dependencies
$ sudo apt-get install libatlas-base-dev libjasper-dev libqtgui4 python3-pyqt5 libqt4-test libilmbase-dev libopenexr-dev libgstreamer1.0-dev libavcodec58 libavformat58 libswscale5
test with env variable set
$ LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libatomic.so.1.2.0 python3
Python 3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>>
The easiest way to do this is using .whl files. When you want to install a package with pip, it searches for a precompiled version of that package that is compatible with your system.
In your case, pip is looking for an OpenCV Python package compatible with armv7l platform, if it cannot find a precompiled .whl file to install, it tries to download the source as .tar.gz and compile it by itself on Raspberry Pi (which is a real pain.)
armv7l compatible .whl files are available for OpenCV Python now and you can use pip to install it directly with pip install opencv-python command but sometimes pip tries to install the latest package and sometimes it is not armv7l compatible. I suggest you check packages and put version specifications to the command.
To handle this situation a lot easier with installations of prerequisites and preparation of the installation environment; you can use complete guides like in this blog post for beginners
As above, trying to install opencv-python.
Normally this would be a simple pip install opencv-python, but it doesn't seem to work. Instead, opencv install to the miniconda directory
/home/pi/miniconda3/lib/python3.5/site-packages
instead of global
/usr/lib/python3.7
Trying to add opencv-python in Thorny through the application fails. In the python program...
import sys
sys.path.append('/home/pi/miniconda3/lib/python3.5/site-packages')
import cv2
results in a
No module named 'cv2.cv2'
I've tried adding it to path also (export PYTHONPATH=/home/pi/miniconda3/lib/python3.5/site-packages:$PYTHONPATH) with no luck.
Because pip is linked to your default Python and I think this default is your miniconda. A better approach is to call the Python version directly with pip. Additionally #Dave W. Smit mentioned that you should better install opencv-python-contrib to use the full OpenCV package (but don´t use both packages!).
$ python-3.7 -m pip install opencv-python-contrib
Or you can use the pip version (if pip is at least version 0.8)
$ pip-3.7 install opencv-python-contrib
Or with pip version 1.5+
$ pip3.7 install opencv-python-contrib
Two days back I ran my model using fastai 0.7.0 on google colab.
And for two days I got busy and now if I am trying to run it , its throwing me an error, on the execution of the line
*"from fastai.transforms import ’ .
the error is AttributeError: module ‘torch’ has no attribute ‘float32’.
The following should get you up and running with the 0.7.0 version of fast.ai (used by v2 of the course) on Google Colab:
!pip install -q "fastai==0.7.0" Pillow==4.1.1 torchtext==0.2.3
!apt-get -qq install -y libsm6 libxext6 && pip install -q -U opencv-python
from wheel.pep425tags import get_abbr_impl, get_impl_ver, get_abi_tag
platform = '{}{}-{}'.format(get_abbr_impl(), get_impl_ver(), get_abi_tag())
# !apt update -q
!apt install -y libsm6 libxext6
from os import path
accelerator = 'cu80' if path.exists('/opt/bin/nvidia-smi') else 'cpu'
torch_whl = f"http://download.pytorch.org/whl/{accelerator}/torch-0.3.0.post4-{platform}-linux_x86_64.whl"
!pip install -q {torch_whl} torchvision image
At-last found what was wrong, there was a compatibility issue.
The pytorch version was 0.3.1 but torchtext version was not compatible with it, has to be “torchtext==0.2.3.”
add below code. i dont really know which dependency call this. but it worked
!pip install -q pandas==0.23.4
!pip install -q joblib==0.12.5
!pip install -q plotly==3.0.0
I'm installing Opencv on Ubuntu with VMWARE following this website.
I finished installing opencv and at Step #6, I put import cv2 and got this error:
[libprotobuf fatal /home/psh/opencv-master/3rdparty/protobuf/src/google
/protobuf/stubs/common.cc:78] This program was compiled against version
2.6.1 of the protocol Buffer runtime library, which is not compatible
with the installed version(3.1.0)...
How can I fix it?
I don't know exactly What is the reason. But I got the same problem like you. But instead of fix this error. I try new way to install OpenCV.
And I follow steps in this website: http://milq.github.io/install-opencv-ubuntu-debian/
Run these commands
sudo apt-get install libopencv-dev python-opencv
sudo apt-get autoremove libopencv-dev python-opencv
Download this script and Run
source install-opencv.sh
After about 1-hour installation, we can test by:
python
import cv2
cv2.__version__
If you want to install OpenCV in your virtualenv too, follow step #5 at this tutorial (your tutorial)
When I try to install scikit-image with pip2 there is show error. I have tried to find this problem solution.
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/scikit-image
Storing debug log for failure in /home/nshakib/.pip/pip.log
My guess is that you might have missing dependencies. I don't think Ubuntu 14.04 comes out of the box with any of the SciPy stack.
To answer your question try,
sudo apt-get install python-matplotlib python-numpy python-pil python-scipy
Then
sudo apt-get install build-essential cython
Finally
sudo apt-get install python-skimage
If that still doesn't work, you could try using the Anaconda Distribution for Python 2.7 from Continuum Analytics.
It comes with many of the major packages built-in and has a great package manager that manages dependencies.
https://docs.continuum.io/anaconda/install#anaconda-install
The conda package would be installed with conda install scikit-image