I have installed opencv using apt-get. I got opencv2 with the following version and it works fine:
rover#rover_pi:/usr/lib/arm-linux-gnueabihf $ python2.7
Python 2.7.13 (default, Nov 24 2017, 17:33:09)
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'2.4.9.1'
Then I wanted to install opencv on a conda environment using pip. I got the following version
(olfatf)rover#rover_pi:/usr/lib/arm-linux-gnueabihf $ pip list | grep opencv
opencv-python 3.4.0.14
However, I get the following error when I import the module:
(olfatf)rover#rover_pi:/usr/lib/arm-linux-gnueabihf $ python
Python 3.4.3 |Continuum Analytics, Inc.| (default, Aug 21 2015, 00:53:08)
[GCC 4.6.3] 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/.conda/envs/olfatf/lib/python3.4/site-packages/cv2/__init__.py", line 3, in <module>
from .cv2 import *
ImportError: libavformat.so.56: cannot open shared object file: No such file or directory
I checked the install libavcodec library and I get the version 57.
(olfatf)rover#rover_pi:/usr/lib/arm-linux-gnueabihf $ ls | grep libavformat
libavformat.a
libavformat.so
libavformat.so.57
libavformat.so.57.56.101
So I want to know why a later version of opencv requires an older version of libavcodec. Also, how can I installed both libavcodec56 and libavcodec57 on my machine ?
I use a raspberry pi with Raspbian Strech
Its not that opencv requires it, Its that whoever compiled the binary of opencv you are using compiled it against libavcodec56. Easiest fix is to compile it yourself.
Also, how can I installed both libavcodec56 and libavcodec57 on my machine ?
Don't. just compile and link against the same version.
Related
I'm currently working on a project with anaconda. I was able to install opencv-python with the regular pip3 install (not anacondas version). When I import cv2, its successful.
Python 3.6.9 (default, Oct 8 2020, 12:12:24)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>>
If I copy that package into my anaconda path, and run python with anaconda, import cv2 I get the following error:
Python 3.7.3 (default, Mar 27 2019, 22:11:17)
[GCC 7.3.0] :: Anaconda, Inc. 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'
Is there a way to get around this without using the Anacondas pip install? I don't have internet on the machine I'm working on. I've done this method with other packages and it has worked fine, not with opencv.
When i use python in terminal ;
pi#raspberrypi:~ $ python
Python 3.7.3 (default, Dec 20 2019, 18:57:59)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
2020-07-26 12:52:03.075590: E tensorflow/core/platform/hadoop/hadoop_file_system.cc:132] HadoopFileSystem load error: libhdfs.so: cannot open shared object file: No such file or directory
>>>
But i tried run my py file
pi#raspberrypi:~ $ sudo python /home/pi/tfdeneme.py
pygame 1.9.4.post1
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File "/home/pi/tfdeneme.py", line 17, in <module>
import tensorflow
ModuleNotFoundError: No module named 'tensorflow'
Im using tensorflow 2.2.0 on my windows machine, on raspberry pi tensorflow version =
pi#raspberrypi:~ $ python
Python 3.7.3 (default, Dec 20 2019, 18:57:59)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
2020-07-26 12:53:49.504578: E tensorflow/core/platform/hadoop/hadoop_file_system.cc:132] HadoopFileSystem load error: libhdfs.so: cannot open shared object file: No such file or directory
>>> tf.__version__
'1.14.0'
Whay should i do to run my py file ?
I was having issues with TF 2.2.0 with python 3.7 and hence downgraded to python 3.6 and now it seems to be working. Please note i am on a Mac though
I am having the following error when I run vtk with python through anaconda
root#user:~# conda install -c clinicalgraphics vtk=7.1.0
Fetching package metadata ...........
Solving package specifications: .
# All requested packages already installed.
# packages in environment at /home/user/anaconda3:
#
vtk 7.1.0 py36_3 clinicalgraphics
root#user~# python
Python 3.6.1 |Anaconda 4.4.0 (64-bit)| (default, May 11 2017, 13:09:58)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import vtk
Traceback (most recent call last):
File "/home/user/anaconda3/lib/python3.6/site-packages/vtk/vtkCommonCore.py", line 5, in <module>
from .vtkCommonCorePython import *
ImportError: /home/user/anaconda3/lib/python3.6/site-packages/vtk/../../../libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /home/user/anaconda3/lib/python3.6/site-packages/vtk/../../../libvtkCommonCorePython36D-7.1.so.1)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/anaconda3/lib/python3.6/site-packages/vtk/__init__.py", line 41, in <module>
from .vtkCommonCore import *
File "/home/user/anaconda3/lib/python3.6/site-packages/vtk/vtkCommonCore.py", line 9, in <module>
from vtkCommonCorePython import *
ModuleNotFoundError: No module named 'vtkCommonCorePython'
I tried using the solution presented in Install vtk with python 3.6 and No module ImportError, they don't seem to work. Surprisingly, I don't face this issue in my Windows distribution. Any alternate suggestion are welcome. I am really trying to avoid downgrading from Python3 to Python2 or using a separate conda environment just for vtk..but if end up doing so...I guess I have to make that work. I tried linking the library of my own build of vtk 8...that doesn't seem to work as well
So I did end up creating a new environment based on menpo vtk=7 python=3 using the following commands
root#user:~# conda create --name VTKpythonENV python=3
.......
root#user:~# conda install -n VTKpythonENV -c menpo vtk=7 python=3
..........
root#user:~# source activate VTKpythonENV
(VTKpythonENV) root#user:~# python
Python 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 13:51:32)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import vtk
This works for me but other suggestions using clinical graphics vtk are also welcome
I installed opencv with home-brew and ran the command import cv in python which gave following error.
I am using MAC OS 10.10 .
What is the issue?
Jays-MacBook-Air:caffe jay$ brew install opencv
Warning: opencv-2.4.10.1 already installed
Jays-MacBook-Air:caffe jay$ python
Python 2.7.9 |Anaconda 2.1.0 (x86_64)| (default, Dec 15 2014, 10:37:34)
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
>>> import cv
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named cv
>>>
What is the error?
Do I need to set path for opencv?
Thank you:)
The first step is find where your cv2.so is with
locate cv2.so.
The output is /usr/local/lib/python2.7/site-packages/cv2.so for my computer.
then, add an additional line
export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH
in ~/.bash_profile to let python find the library.
I installed latest version of miniconda on a linux 64-bit filesystem that does not allow hard links (openAFS).
These are installation steps:
run installer until it fails on hard link errors
then modify install.py specified in $CONDA_INSTALL adding two line at the top of _link function
if linktype==HARD_LINK:
linktype=SOFT_LINK
now execute $PYTHON $CONDA_INSTALL --prefix=$PREFIX --pkgs-dir=$PREFIX/pkgs --link-all and everything works
The problem is that even if python is correctly installed,
> miniconda/bin/python
Python 2.7.6 |Continuum Analytics, Inc.| (default, Jan 17 2014, 10:13:17)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
I cannot run conda:
> miniconda/bin/conda
Traceback (most recent call last):
File "miniconda/bin/conda", line 3, in <module>
from conda.cli import main
ImportError: No module named conda.cli
I tried to set $PATH and/or $PYTHONPATH and/or $LD_LIBRARY_PATH but without success.
Is there a way to solve this issue? Is there a way to force soft link in place of hard link during installation?
Thanks,
Angelo