How to overcome import error with opencv in ipython - opencv

I believe I finally installed OpenCV using the following command.
conda install -c anaconda opencv 
it seems I can load opencv in python3
however, when I try to import this in ipython or jupyter, I get the following:
In [1]: import cv2
ImportError Traceback (most recent call last)
<ipython-input-1-72fbbcfe2587> in <module>()
----> 1 import cv2
ImportError: dlopen(/Users/mycomputer/anaconda/lib/python3.6/site-packages/cv2.cpython-36m-darwin.so, 2): Library not loaded: #rpath/libintl.8.dylib
Referenced from: /Users/mycomputer/anaconda/lib/libharfbuzz.0.dylib
Reason: image not found

By run this command:pip install opencv-python, I fixed this issue.

Related

How to fix numpy fail with missing libcblas.so.3 on alpine docker

I had installed numpy on alpine docker and everything looked good before running numpy:
Traceback (most recent call last):
File "/app/venv/lib/python3.7/site-packages/numpy/core/__init__.py", line 24, in <module>
from . import multiarray
File "/app/venv/lib/python3.7/site-packages/numpy/core/multiarray.py", line 14, in <module>
from . import overrides
File "/app/venv/lib/python3.7/site-packages/numpy/core/overrides.py", line 7, in <module>
from numpy.core._multiarray_umath import (
ImportError: Error loading shared library libcblas.so.3: No such file or directory (needed by /app/venv/lib/python3.7/site-packages/numpy/core/_multiarray_umath.cpython-37m-x86_64-linux-gnu.so)
I found that licblas.so might be in /usr/lib/ as mentioned here: alpine blas
but it wasn't there.
After installing lapack, the missing file libcblas.so.3 appeared in /usr/lib/:
apk add lapack
I had openblas-dev installed from before but that was not sufficient.

Issues installing Drake on Ubuntu 18.04

Followed through installation tips, but after typing
$ python underactuated/src/double_pendulum/simulate.py
I get
ImportError: dynamic module does not define init function (init_module_py).
If I run python3 I get
ImportError: cannot import name 'FindResource'.
After typing $ python3 -c 'import pydrake; print(pydrake.__file__)' I get /opt/drake/lib/python3.6/site-packages/pydrake/__init__.py
Edit:
Full output of running python3
Traceback (most recent call last):
File "underactuated/src/double_pendulum/simulate.py", line 5, in <module>
from underactuated import FindResource, PlanarSceneGraphVisualizer
ImportError: cannot import name 'FindResource'
And full output of running python (without3):
Traceback (most recent call last):
File "underactuated/src/double_pendulum/simulate.py", line 1, in <module>
from pydrake.all import (AddMultibodyPlantSceneGraph,
File "/opt/drake/lib/python3.6/site-packages/pydrake/__init__.py", line 32, in <module>
from . import common
File "/opt/drake/lib/python3.6/site-packages/pydrake/common/__init__.py", line 3, in <module>
from ._module_py import *
ImportError: dynamic module does not define init function (init_module_py)
Version of python after typing python -V is Python 2.7.15+
The fact that the print test succeeds suggests that drake is installed correctly.
Please post the full output of running simulate.py with python3.

How install utils on colab?

How manually install util on google colab?
!pip install web.py==0.40.dev0
import utils
Error
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-13-a4c82eaa1619> in <module>()
20 import torch.backends.cudnn
21 get_ipython().system('pip install web.py==0.40.dev0')
---> 22 from Utils import *
23 from PIL import Image
24 from torch import nn
ModuleNotFoundError: No module named 'Utils'
---------------------------------------------------------------------------
How to correct this mistake correctly?
try change to !pip install python-utils but
Installing collected packages: python-utils
**Successfully installed python-utils-2.3.0**
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-e6796b5aa862> in <module>()
20 import torch.backends.cudnn
21 get_ipython().system('pip install python-utils')
---> 22 import utils
23 from PIL import Image
24 from torch import nn
ModuleNotFoundError: **No module named 'utils'**
please try this if this may help in your code
!install pip
!pip install utils
import utils

Graphviz not working using conda or pip [duplicate]

This question already has answers here:
anaconda - graphviz - can't import after installation
(14 answers)
Closed 3 years ago.
I cannot get graphviz to install and import properly, either using conda install or pip install. I am using jupyter on anaconda.
conda install -c anaconda graphviz
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-0e78fd6401bd> in <module>()
----> 1 import graphviz
2 dot_data = tree.export_graphviz(clf, out_file=None)
3 graph = graphviz.Source(dot_data)
4 graph.render("iris")
ModuleNotFoundError: No module named 'graphviz'
When I install using pip I can successfully import but when I run the below code, I get a very long error message that ends with the following when running graph.render:
from sklearn.datasets import load_iris
from sklearn import tree
import graphviz
iris = load_iris()
clf = tree.DecisionTreeClassifier()
clf = clf.fit(iris.data, iris.target)
dot_data = tree.export_graphviz(clf, out_file=None)
graph = graphviz.Source(dot_data)
graph.render("iris")
Below is the end of the end of a long error message:
ExecutableNotFound: failed to execute ['dot', '-Tpdf', '-O', 'iris'], make sure the Graphviz executables are on your systems' PATH
I have the directory where the graphviz folders are in PATH.
Anyone have an idea what I am doing wrong?
http://www.graphviz.org/Download_windows.php
Install windows package from: http://www.graphviz.org/Download_windows.php
Install python graphviz package
Add C:\Program Files (x86)\Graphviz2.38\bin to User path
Add C:\Program Files (x86)\Graphviz2.38\bin\dot.exe to System Path
RESTART COMPUTER
Worked for me!
If you're running Linux, you may have to run this command in addition to the Conda command (I had to do this):
sudo apt-get install graphviz
I was getting the exact same error in Pycharm and this solved it.

I properly installed PIL but still get the No Module Error

Grizz-MacBook-Pro:~ Grizz$ cd /usr/local/lib/python2.7/site-packages
Grizz-MacBook-Pro:site-packages Grizz$ ls
PIL pip-6.0.8-py2.7.egg
Pillow-2.7.0-py2.7.egg-info setuptools-12.0.5-py2.7.egg
PyQt4 setuptools.pth
easy-install.pth sip.so
hgext sipconfig.py
homebrew-pillow-nose.pth sipdistutils.py
mercurial sitecustomize.py
mercurial-3.3-py2.7.egg-info sitecustomize.pyc
It looks like PIL is installed in the correct PATH and when I go to use it in Sublime I get the:
'Traceback (most recent call last):
File "/Users/Grizz/Documents/Python Files/Weather APP/WeatherApp.py", line 4, in <module>
from PIL import Image
ImportError: No module named PIL
[Finished in 0.1s with exit code 1]
[shell_cmd: python -u "/Users/Grizz/Documents/Python Files/Weather APP/WeatherApp.py"]
[dir: /Users/Grizz/Documents/Python Files/Weather APP]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
I'm hoping to figure out either how to change the PIL path to ammend it to my system python path so I can run it in my interpreter or to uninstal and redownload PIL the correct way.
I'm new to Mac OS and have been able to troubleshoot most everything until now. I'm guessing it's because I'm running off my sys Python 2.7 and not a brew installeld 2.7... can someone walk me through this?

Resources