import cv2 returns error in jupyter notebook with python 3.6 - opencv

I need to download opencv to run a project that requires python 3.6 and opencv. I have downloaded opencv.
I know my error is similar to OpenCV giving an error whenever import cv2 is used but I have tried both of the solutions mentioned in that question and neither works for me.
!pip install opencv-python
Requirement already satisfied: opencv-python in /Users/aa/.conda/envs/py36/lib/python3.6/site-packages (3.4.2.16)
Requirement already satisfied: numpy>=1.11.3 in /Users/aa/.conda/envs/py36/lib/python3.6/site-packages (from opencv-python) (1.18.3)
but when i typed
import cv2
I got the following error:
ImportError Traceback (most recent call last)
<ipython-input-27-c8ec22b3e787> in <module>
----> 1 import cv2
~/.conda/envs/py36/lib/python3.6/site-packages/cv2/__init__.py in <module>
1 import importlib
2
----> 3 from .cv2 import *
4 from .data import *
5
ImportError: dlopen(/Users/aa/.conda/envs/py36/lib/python3.6/site-packages/cv2/cv2.cpython-36m-darwin.so, 2): Symbol not found: __ZN10QBoxLayout10invalidateEv
Referenced from: /Users/aa/.conda/envs/py36/lib/python3.6/site-packages/cv2/cv2.cpython-36m-darwin.so
Expected in: /Users/aa/.conda/envs/py36/lib/python3.6/site-packages/cv2/.dylibs/QtGui
in /Users/aa/.conda/envs/py36/lib/python3.6/site-packages/cv2/cv2.cpython-36m-darwin.so
I also tried to use conda to install but I always got the following error:
Proceed ([y]/n)? y
Preparing transaction: failed
>>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
Traceback (most recent call last):
File "/anaconda2/lib/python2.7/site-packages/conda/exceptions.py", line 819, in __call__
return func(*args, **kwargs)
File "/anaconda2/lib/python2.7/site-packages/conda/cli/main.py", line 78, in _main
exit_code = do_call(args, p)
File "/anaconda2/lib/python2.7/site-packages/conda/cli/conda_argparse.py", line 77, in do_call
exit_code = getattr(module, func_name)(args, parser)
File "/anaconda2/lib/python2.7/site-packages/conda/cli/main_install.py", line 11, in execute
install(args, parser, 'install')
File "/anaconda2/lib/python2.7/site-packages/conda/cli/install.py", line 253, in install
handle_txn(unlink_link_transaction, prefix, args, newenv)
File "/anaconda2/lib/python2.7/site-packages/conda/cli/install.py", line 282, in handle_txn
unlink_link_transaction.execute()
File "/anaconda2/lib/python2.7/site-packages/conda/core/link.py", line 223, in execute
self.verify()
File "/anaconda2/lib/python2.7/site-packages/conda/common/io.py", line 46, in decorated
return f(*args, **kwds)
File "/anaconda2/lib/python2.7/site-packages/conda/core/link.py", line 200, in verify
self.prepare()
File "/anaconda2/lib/python2.7/site-packages/conda/core/link.py", line 192, in prepare
stp.remove_specs, stp.update_specs)
File "/anaconda2/lib/python2.7/site-packages/conda/core/link.py", line 282, in _prepare
mkdir_p(transaction_context['temp_dir'])
File "/anaconda2/lib/python2.7/site-packages/conda/gateways/disk/__init__.py", line 60, in mkdir_p
makedirs(path)
File "/anaconda2/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/anaconda2/.condatmp'

Related

Use pytorch on Alpine

I have a docker image in alpine, and need to use pytorch on it. However, as stated in the pytorch website, it requires glibc to run, otherwise it will give error below
import torch
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.7/site-packages/torch/__init__.py", line 189, in <module>
_load_global_deps()
File "/usr/lib/python3.7/site-packages/torch/__init__.py", line 142, in _load_global_deps
ctypes.CDLL(lib_path, mode=ctypes.RTLD_GLOBAL)
File "/usr/lib/python3.7/ctypes/__init__.py", line 364, in __init__
self._handle = _dlopen(self._name, mode)
OSError: Error relocating /usr/lib/python3.7/site-packages/torch/lib/libgomp-7c85b1e2.so.1: pthread_attr_setaffinity_np: symbol not found
I've tried to install glibc from https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.29-r0/glibc-2.29-r0.apk, but error info stay the same.

CKAN Docker install seems perfect except ckan container exits immediately after a restart

My CKAN Docker install seems perfect except that the ckan container exits immediately after a restart.strong textI have repeatedly tried a rebuild of the docker containers. I see no errors except a reference to the deprecation of python2. Please advise on any issues that I may have overlooked or something missing. This installation is on Ubuntu 19.10.
docker log is as follows:
Command 'db' not known (you may need to run setup.py egg_info)
Known commands:
create Create the file layout for a Python distribution
Traceback (most recent call last):
File "/usr/local/bin/ckan-paster", line 8, in <module>
sys.exit(run())
File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/paste/script/command.py", line 102, in run
invoke(command, command_name, options, args[1:])
File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/paste/script/command.py", line 141, in invoke
exit_code = runner.run(args)
File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/paste/script/command.py", line 806, in run
command.load().summary))
File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2321, in load
return self.resolve()
File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2327, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/ckan/venv/src/ckan/ckanext/datapusher/cli.py", line 7, in <module>
import ckan.lib.cli as cli
File "/usr/lib/ckan/venv/src/ckan/ckan/lib/cli.py", line 17, in <module>
from ckan.cli import load_config as _get_config
File "/usr/lib/ckan/venv/src/ckan/ckan/cli/__init__.py", line 8, in <module>
from configparser import ConfigParser
ImportError: No module named configparser
Command 'db' not known (you may need to run setup.py egg_info)
Known commands:
create Create the file layout for a Python distribution
Traceback (most recent call last):
File "/usr/local/bin/ckan-paster", line 8, in <module>
sys.exit(run())
File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/paste/script/command.py", line 102, in run
invoke(command, command_name, options, args[1:])
File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/paste/script/command.py", line 141, in invoke
exit_code = runner.run(args)
File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/paste/script/command.py", line 806, in run
command.load().summary))
File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2321, in load
return self.resolve()
File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2327, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/ckan/venv/src/ckan/ckanext/datapusher/cli.py", line 7, in <module>
import ckan.lib.cli as cli
File "/usr/lib/ckan/venv/src/ckan/ckan/lib/cli.py", line 17, in <module>
from ckan.cli import load_config as _get_config
File "/usr/lib/ckan/venv/src/ckan/ckan/cli/__init__.py", line 8, in <module>
from configparser import ConfigParser
ImportError: No module named configparser
Traceback (most recent call last):
File "/usr/local/bin/ckan-paster", line 8, in <module>
Command 'db' not known (you may need to run setup.py egg_info)
Known commands:
create Create the file layout for a Python distribution
sys.exit(run())
File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/paste/script/command.py", line 102, in run
invoke(command, command_name, options, args[1:])
File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/paste/script/command.py", line 141, in invoke
exit_code = runner.run(args)
File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/paste/script/command.py", line 806, in run
command.load().summary))
File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2321, in load
return self.resolve()
File "/usr/lib/ckan/venv/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2327, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/ckan/venv/src/ckan/ckanext/datapusher/cli.py", line 7, in <module>
import ckan.lib.cli as cli
File "/usr/lib/ckan/venv/src/ckan/ckan/lib/cli.py", line 17, in <module>
from ckan.cli import load_config as _get_config
File "/usr/lib/ckan/venv/src/ckan/ckan/cli/__init__.py", line 8, in <module>
from configparser import ConfigParser
ImportError: No module named configparser
You are using python 2.7 but importing configparser, which is Python 3 module. Check which version you are pooling from the Docker, I think you need 2.8.x tag as the latest stable.

Drake installation issues on Mac

1) I built the visualizer but couldn’t launch it. Here is what I see:
(base) Taos-MacBook-Pro:drake taosun$ bazel build //tools:drake_visualizer //manipulation/util:geometry_inspector
INFO: Analyzed 2 targets (0 packages loaded, 0 targets configured).
INFO: Found 2 targets...
INFO: Elapsed time: 0.988s, Critical Path: 0.01s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
But when I tried to launch it, it didn't work:
(base) Taos-MacBook-Pro:drake taosun$ ./bazel-bin/tools/drake_visualizer
Traceback (most recent call last):
File "/usr/local/opt/vtk#8.2/lib/python3.7/site-packages/vtkmodules/vtkIOAMR.py", line 5, in <module>
from .vtkIOAMRPython import *
ImportError: dlopen(/usr/local/opt/vtk#8.2/lib/python3.7/site-packages/vtkmodules/vtkIOAMRPython.so, 2): Library not loaded: /usr/local/opt/hdf5/lib/libhdf5.103.dylib
Referenced from: /usr/local/opt/vtk#8.2/lib/libvtkIOAMR-8.2.1.dylib
Reason: image not found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/tmp/_bazel_taosun/faebfa4431921ca82cfb8e7cf6a74cad/external/drake_visualizer/lib/python3.7/site-packages/director/drakevisualizerapp.py", line 3, in <module>
from director import mainwindowapp
File "/private/var/tmp/_bazel_taosun/faebfa4431921ca82cfb8e7cf6a74cad/external/drake_visualizer/lib/python3.7/site-packages/director/mainwindowapp.py", line 2, in <module>
from director.componentgraph import ComponentFactory
File "/private/var/tmp/_bazel_taosun/faebfa4431921ca82cfb8e7cf6a74cad/external/drake_visualizer/lib/python3.7/site-packages/director/componentgraph.py", line 2, in <module>
from director.fieldcontainer import FieldContainer
File "/private/var/tmp/_bazel_taosun/faebfa4431921ca82cfb8e7cf6a74cad/external/drake_visualizer/lib/python3.7/site-packages/director/fieldcontainer.py", line 1, in <module>
import vtk
File "/usr/local/opt/vtk#8.2/lib/python3.7/site-packages/vtk.py", line 32, in <module>
all_spec.loader.exec_module(all_m)
File "/usr/local/opt/vtk#8.2/lib/python3.7/site-packages/vtkmodules/all.py", line 67, in <module>
from .vtkIOAMR import *
File "/usr/local/opt/vtk#8.2/lib/python3.7/site-packages/vtkmodules/vtkIOAMR.py", line 9, in <module>
from vtkIOAMRPython import *
ModuleNotFoundError: No module named 'vtkIOAMRPython'
2) I also tried python-binding. The cmake and make completed successfully. However, when I tried to import pydrake, I got the below error:
(base) Taos-MacBook-Pro:GitHub taosun$ cd drake-build
(base) Taos-MacBook-Pro:drake-build taosun$ python3 -c 'import pydrake; print(pydrake.__file__)'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/opt/drake/lib/python3.7/site-packages/pydrake/__init__.py", line 41, in <module>
from . import common
File "/opt/drake/lib/python3.7/site-packages/pydrake/common/__init__.py", line 1, in <module>
from ._module_py import *
ImportError: dlopen(/opt/drake/lib/python3.7/site-packages/pydrake/common/_module_py.so, 2): Symbol not found: _PyThread_tss_alloc
Referenced from: /opt/drake/lib/python3.7/site-packages/pydrake/common/_module_py.so
Expected in: flat namespace
in /opt/drake/lib/python3.7/site-packages/pydrake/common/_module_py.so
For both of the above two issues, I doubt whether it is because I don’t set $PYTHONPATH correctly. This is what I set at the moment
(base) Taos-MacBook-Pro:drake-build taosun$ echo $PYTHONPATH
/opt/drake/lib/python3.7/site-packages
Thank you for the help!
For the VTK error, try adding --define="-DUSE_SYSTEM_VTK=OFF" at the end of your build command.
bazel build //tools:drake_visualizer //manipulation/util:geometry_inspector --define="-DUSE_SYSTEM_VTK=OFF"`

ImportError: libcudnn.so.6: cannot open shared object file: No such file or directory Tensorflow

I cannot get it to work! Been trying for almost two days now. Installed Cuda8 and CuDnn 6 - didn't work. added the solution written in ImportError: libcudnn when running a TensorFlow program here.
The error I'm getting -
Traceback (most recent call last):
File "/home/shenath/tensorflow/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/shenath/tensorflow/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/shenath/tensorflow/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/home/shenath/tensorflow/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/home/shenath/tensorflow/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: libcudnn.so.6: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/shenath/tensorflow/lib/python3.5/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/shenath/tensorflow/lib/python3.5/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/shenath/tensorflow/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/shenath/tensorflow/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/shenath/tensorflow/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/shenath/tensorflow/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/home/shenath/tensorflow/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/home/shenath/tensorflow/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: libcudnn.so.6: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
I am new to this. Any help will be really appreciated. If you need anymore info I'll be happy to provide.
Make sure they are in the correct directory after you install cuda and cudnn.
Run the following command after installing cudnn 6. Tensorflow only checks the required file on you cuda directory. So we copy or link the required files from cudnn to that directory.
mkdir /usr/lib/x86_64-linux-gnu/include/ && \
ln -s /usr/lib/x86_64-linux-gnu/include/cudnn.h /usr/lib/x86_64-linux-gnu/include/cudnn.h && \
ln -s /usr/include/cudnn.h /usr/local/cuda/include/cudnn.h && \
ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudnn.so &&
ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.6 /usr/local/cuda/lib64/libcudnn.so.6
So, if you are still having that error make sure follow the steps here.

Error in py2app

I am testing py2app on a simple test.py application, doing nothing special.
python == 3.6
py2app == 0.14
It builds fine with no errors when I give this command:
python3.6 setup.py py2app -A
but when I launch it, this is the result:
./dist/test.app/Contents/MacOS/test
Traceback (most recent call last):
File "/Users/fabio/projvenv/dist/test.app/Contents/Resources/__boot__.py", line 132, in <module>
_run()
File "/Users/fabio/projvenv/dist/test.app/Contents/Resources/__boot__.py", line 126, in _run
exec(compile(source, script, 'exec'), globals(), globals())
File "/Users/fabio/projvenv/test.py", line 3, in <module>
import tkinter
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ValueError: character U+6573552f is not in range [U+0000; U+10ffff]
2017-06-24 11:32:26.266 test[65341:8804502] test Error
downgrading to 0.12 fixed the issue for me. More of a workaround that a fix though but good enough for me at this point

Resources