I tested the following command in python:
import cv2
I put it in the file b.py and run python b.py. But I met with the following error:
Traceback (most recent call last):
File "b.py", line 1, in <module>
import cv2
File "/home/mypath/anaconda2/lib/python2.7/site-packages/cv2/__init__.py", line 9, in <module>
from .cv2 import *
ImportError: libXdmcp.so.6: cannot open shared object file: No such file or directory
What's wrong with this? Thank you all for helping me!
Did you install opencv correctly? Also what OS are you using (e.g. Windows, Linux OS X etc.)
If you're using windows - did you follow these steps?:
http://docs.opencv.org/3.2.0/d5/de5/tutorial_py_setup_in_windows.html
If you are using Fedora install Opencv by typing this command into the terminal:
sudo yum install numpy opencv*
The cause of the problem may be that you haven't installed the dependencies:
Matplotlib
Numpy
Hope this helps!
Related
I'm getting this weird runtime (I think) error with cv2 (assumingly) and cannnot resolve it.
i'm using python3.7 on mac:
(proj) user#user-MacBook-Pro:~/Desktop/proj/controllers$ python
Experiments/n_Experiment.py
pybullet build time: Dec 10 2021 09:53:34
Traceback (most recent call last):
File "Experiments/n_Experiment.py", line 1, in <module>
from experiment import Experiment
File "/Users/user/Desktop/proj/ontrollers/experiment.py", line 1, in <module>
from simulation import LinkServer as SimServer
File "/Users/user/Desktop/proj/controllers/pybulletsim/simulation.py", line 11, in <module>
import cv2
ImportError: dlopen(/Users/user/opt/anaconda3/envs/proj/lib/python3.7/site- packages/cv2.cpython-37m-darwin.so, 2): Symbol not found: _av_buffer_default_free
Referenced from: /Users/user/opt/anaconda3/envs/proj/lib/libavformat.58.dylib
Expected in: /Users/user/opt/anaconda3/envs/proj/lib/libavcodec.58.dylib
in /Users/user/opt/anaconda3/envs/proj/lib/libavformat.58.dylib
So far, I've tried to update conda, and all of the following actions which did not help:
update conda navigtors
symbolyc link
ln -s libavformat.58.dylib
reinstall opencv in various ways (using conda, pip3, brew (also tried to brew build from source).
reinstall numpy (there might be a connection apparently).
Any ideas how to resolve it??
Thanks!
I am using Python3.6 on CentOS linux and have created virtual environment using venv. I installed matplotlib using pip install matplotlib and it completed successfully. Now when I am trying to import matplotlib in python command line it is producing Import Error:
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/yogeshs/Python3.6VE/lib/python3.6/site-packages/matplotlib/__init__.py", line 127, in <module>
from . import cbook
File "/home/yogeshs/Python3.6VE/lib/python3.6/site-packages/matplotlib/cbook/__init__.py", line 13, in <module>
import bz2
ImportError: dynamic module does not define module export function (PyInit_bz2)
>>>
I read almost all the answers on similar issues on Stackoverflow and tried to follow the steps but I am unable to to resolve this problem. Can somebody please guide me through this? Thank you in advance.
I want to use Python for trying out hddm.
I installed anaconda, Python 2.7. When I try to follow the hddm tutorial in the command line window in spyder, the following happens, which seems to be a problem in pymc:
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
import hddm
Traceback (most recent call last):
File "<ipython-input-24-17365318b31c>", line 1, in <module>
import hddm
File "/Users/c/anaconda/lib/python2.7/site-packages/hddm/__init__.py", line 7, in <module>
import likelihoods
File "/Users/c/anaconda/lib/python2.7/site-packages/hddm/likelihoods.py", line 2, in <module>
import pymc as pm
File "/Users/c/anaconda/lib/python2.7/site-packages/pymc/__init__.py", line 31, in <module>
from .distributions import *
File "/Users/c/anaconda/lib/python2.7/site-packages/pymc/distributions.py", line 30, in <module>
from . import flib, utils
ImportError: cannot import name flib
I work on Mac OS X 10.7. On the web, I find some comments concerning pymc possibly not being compiled with the correct version of gfortran, but the solutions all seem to be for windows. Also, I thought that this kind of problem should not happen with an integrated system like Anaconda?
There are two options:
use conda install -c conda.binstar.org/pymc pymc
install gfortran and use pip install -U pymc
I'm using sublime text 2 to run python 2.7. I have downloaded and installed mathplotlib. When I type the code:
import matplotlib.pyplot
I'm getting this error.
Traceback (most recent call last):
File "/Volumes/HP v190b/Python - Squash Coursework/squashFINAL.py", line 212, in <module>
import matplot.pyplot as plt
ImportError: No module named matplot.pyplot
Any ideas why? I'm using a Mac!
You may check the dependencies, sometimes you need to install some dependencies so that you can import certain module, take a look at this link http://matplotlib.org/users/installing.html
I followed the instructions at https://gist.github.com/2778301 but when I try to do import PythonMagick I get the error message:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "PythonMagick/__init__.py", line 1, in <module>
from . import _PythonMagick
ImportError: cannot import name _PythonMagick
The PythonMagick.so is in my python2.7 site-packages.
EDIT:
I solved this problem by copying from where make install installed PythonMagick /usr/local/lib/python2.7/site-packages/PythonMagick to where Python actually looks on a OS X Lion, /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/
There's an answer to your question on the link you provided:
This can be fixed by changing the first line of __init__.py in PythonMagick, which is usually found in the site-packages directory, for instance,
python2.7/site-packages/PythonMagick
Try changing:
from . import _PythonMagick
to
import _PythonMagick