ImportError: libopencv_hdf.so.3.1: cannot open shared object file: No such file or directory - python-3.x

I am trying to run my test cases in Bitbucket-pipeline but it is showing
an error message.
Screenshot of Bitbucket-pipeline.yml
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> import cv2
E ImportError: libopencv_hdf.so.3.1: cannot open shared object file: No such file or directory
**ImportError**

You could didn't install opencv3.1 or didn't install correctly that's why you can't import it.

Thanks, I found the answer. I was installing opencv redundant time, so it was overlapping and deleting some important module from itself.
This is my script from Bitbucket-pipeline.yml
image: python:3.6.2
pipelines:
default:
- step:
caches:
- condacache
script:
- wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
- chmod +x Miniconda3-latest-Linux-x86_64.sh
- ./Miniconda3-latest-Linux-x86_64.sh -u -b -p /opt/python
- cd marvin_oms
- /opt/python/bin/conda update -y conda
- /opt/python/bin/pip install --upgrade pip
- /opt/python/bin/conda install -y numpy pandas SQLAlchemy requests lxml virtualenv psycopg2
- apt-get update && apt-get install -y libzbar0 libzbar-dev libgtk2.0-0
- /opt/python/bin/pip install pyzbar
- /opt/python/bin/conda install seaborn opencv=3.1.0 scipy libgcc boost=1.61.0 libpng=1.6.27 cython
- /opt/python/bin/pip install libraries/imgforensics-0.1-cp36-cp36m-linux_x86_64.whl
- /opt/python/bin/pip install -r requirements.txt
- /opt/python/bin/pytest
definitions:
caches:
condacache: /opt/python/bin

that's because you might have pasted another cv2.so file which is overlapping go ahead and open a terminal and type
cd /lib/python3/dist-packages
and then
ls
you will see cv2.so , copy it on desktop as a backup so incase if i am wrong you won't lose it
type :
cp cv2.so /home/ubuntu/cv2.so
and then type this to delete it
rm cv2.so
now type
python3
import cv2
and you're done ...
a proof of concept :
check here the image
and after deleting it :
last one after importing

Related

Bazel error: An error occurred while getting the repository "npm"

I recently cloned Google's js-examples repository that uses Bazel to run and build. On running the code in my computer, I kept getting the error "An error occurred while getting the repository npm"
I'm totally new to using bazel. Has anyone encountered such issue and how did you go about it?
Below is the link to the repo
The link to the js-examples repo on github
enter image description here
Above is the link to the error message
This is what I think is bazel trying to get npm
def _npm_install_impl(repository_ctx):
"""Core implementation of npm_install."""
_check_min_bazel_version("npm_install", repository_ctx)
is_windows_host = is_windows_os(repository_ctx)
node = repository_ctx.path(get_node_label(repository_ctx))
npm = get_npm_label(repository_ctx)
# Set the base command (install or ci)
npm_args = [repository_ctx.attr.npm_command]
npm_args.extend(repository_ctx.attr.args)
# Run the package manager in the package.json folder
if repository_ctx.attr.symlink_node_modules:
root = str(repository_ctx.path(repository_ctx.attr.package_json).dirname)
else:
root = str(repository_ctx.path(_workspace_root_prefix(repository_ctx)))
# The entry points for npm install for osx/linux and windows
if not is_windows_host:
# Prefix filenames with _ so they don't conflict with the npm package `npm`
repository_ctx.file(
"_npm.sh",
content = """#!/usr/bin/env bash# Immediately exit if any command fails. set -e (cd "{root}"; "{npm}" {npm_args})""".format(
root = root,
npm = repository_ctx.path(npm),
npm_args = " ".join(npm_args),
),
executable = True,
)
else:
repository_ctx.file(
"_npm.cmd",
content = """#echo off cd /D "{root}" && "{npm}" {npm_args}""".format(
root = root,
npm = repository_ctx.path(npm),
npm_args = " ".join(npm_args),
),
executable = True,
)
_symlink_file(repository_ctx, repository_ctx.attr.package_lock_json)
_copy_file(repository_ctx, repository_ctx.attr.package_json)
_copy_data_dependencies(repository_ctx)
_add_scripts(repository_ctx)
_add_node_repositories_info_deps(repository_ctx)
result = repository_ctx.execute(
[node, "pre_process_package_json.js", repository_ctx.path(repository_ctx.attr.package_json), "npm"],
quiet = repository_ctx.attr.quiet,
)
if result.return_code:
fail("pre_process_package_json.js failed: \nSTDOUT:\n%s\nSTDERR:\n%s" % (result.stdout, result.stderr))
env = dict(repository_ctx.attr.environment)
env_key = "BAZEL_NPM_INSTALL"
if env_key not in env.keys():
env[env_key] = "1"
env["BUILD_BAZEL_RULES_NODEJS_VERSION"] = VERSION
repository_ctx.report_progress("Running npm install on %s" % repository_ctx.attr.package_json)
result = repository_ctx.execute(
[repository_ctx.path("_npm.cmd" if is_windows_host else "_npm.sh")],
timeout = repository_ctx.attr.timeout,
quiet = repository_ctx.attr.quiet,
environment = env,
)
if result.return_code:
fail("npm_install failed: %s (%s)" % (result.stdout, result.stderr))
remove_npm_absolute_paths = Label("//third_party/github.com/juanjoDiaz/removeNPMAbsolutePaths:bin/removeNPMAbsolutePaths")
# removeNPMAbsolutePaths is run on node_modules after npm install as the package.json files
# generated by npm are non-deterministic. They contain absolute install paths and other private
# information fields starting with "_". removeNPMAbsolutePaths removes all fields starting with "_".
print([node, repository_ctx.path(remove_npm_absolute_paths), root + "/node_modules"])
result = repository_ctx.execute(
[node, repository_ctx.path(remove_npm_absolute_paths), root + "/node_modules"],
)
if result.return_code:
fail("remove_npm_absolute_paths failed: %s (%s)" % (result.stdout, result.stderr))
_symlink_node_modules(repository_ctx)
_create_build_files(repository_ctx, "npm_install", node, repository_ctx.attr.package_lock_json)

"pynvml.NVMLError_LibraryNotFound: NVML Shared Library Not Found" in bitbucket-pipelines

I am trying to execute the following bitbucket-pipelines config:
clone:
depth: full
options:
max-time: 4 # maximum minutes to run the tests
pipelines:
pull-requests: # run when pull request is created (or updated)
"**": # this runs as default for any branch not elsewhere defined
- step:
name: Tests # name to show on the pipelines web page
image: python:3.7 # docker to use (from Docker Hub)
script: # shell commands to run
- pip install -r requirements.txt
- python -m pytest --junitxml=./test-reports/junit.xml .
However, when the unitests are executed i get the following errors (in bitbucket-pipeline):
pynvml.NVMLError_LibraryNotFound: NVML Shared Library Not Found
def _LoadNvmlLibrary():
'''
Load the library if it isn't loaded already
'''
global nvmlLib
if (nvmlLib == None):
# lock to ensure only one caller loads the library
libLoadLock.acquire()
try:
# ensure the library still isn't loaded
if (nvmlLib == None):
try:
if (sys.platform[:3] == "win"):
# cdecl calling convention
# load nvml.dll from %ProgramFiles%/NVIDIA Corporation/NVSMI/nvml.dll
nvmlLib = CDLL(os.path.join(os.getenv("ProgramFiles", "C:/Program Files"), "NVIDIA Corporation/NVSMI/nvml.dll"))
else:
# assume linux
> nvmlLib = CDLL("libnvidia-ml.so.1")
/usr/local/lib/python3.7/site-packages/pynvml.py:644:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <CDLL 'libnvidia-ml.so.1', handle 0 at 0x7fcc75c8a910>
name = 'libnvidia-ml.so.1', mode = 0, handle = None, use_errno = False
use_last_error = False
def __init__(self, name, mode=DEFAULT_MODE, handle=None,
use_errno=False,
use_last_error=False):
self._name = name
flags = self._func_flags_
if use_errno:
flags |= _FUNCFLAG_USE_ERRNO
if use_last_error:
flags |= _FUNCFLAG_USE_LASTERROR
if _sys.platform.startswith("aix"):
"""When the name contains ".a(" and ends with ")",
e.g., "libFOO.a(libFOO.so)" - this is taken to be an
archive(member) syntax for dlopen(), and the mode is adjusted.
Otherwise, name is presented to dlopen() as a file argument.
"""
if name and name.endswith(")") and ".a(" in name:
mode |= ( _os.RTLD_MEMBER | _os.RTLD_NOW )
class _FuncPt
After reading issues, it seems that it related to NVidia drivers. However, i'm not sure if it is the case. In if it is the case, how can i fix these issues.

Missing something fundamental with my (first) setup.py - Python 3.4

I'm missing something fundamental with how my setup.py should look. I've tried many, many tweaks but to no avail. Please note that since I'm just doing an installer for just a single module, I chose to use py_module = ['foo'] instead of pacakges = ['foo']. I tried packages with an additional rss_parse subdirectory as well, but still no dice. Clearly there's something from the docs that I either misunderstood, or missed entirely.
Directory:
~/rss_parse
|- __init__.py
|- README.md
|- rss_parse.py
|- setup.py
setup.py:
from setuptools import setup
setup(name = 'rss_parse',
version ='0.1.0b1',
description ='RSS feed parser: Takes a URL and configuration dict and '
'returns an iterable object containing feed `<items>`',
long_description = open('README.md', 'r').read(),
author = 'Alastair',
author_email = 'nope#nopenope.nope',
url = 'https://github.com/dev-dull/rss_parse',
license = 'MIT',
py_module = ['rss_parse'],
install_requires = ['arrow', 'lxml'],
classifiers = [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Topic :: Software Development :: RSS and Atom feed parsing.',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.4',
],
keywords = 'RSS parser xml news Atom feed',
)
installing:
user#linux:~/rss_parse$ python3 setup.py install --user
testing:
user#linux:~/rss_parse$ cd ~/Desktop # make sure python3 doesn't find it in ./
user#linux:~/Desktop$ python3
>>> import rss_parse
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'rss_parse'
py_modules not py_module.
"There once was a woman from Venus..." - Lt. Cmdr. Data

R-program - igraph package error

I have encountered an error message in an R Program (see code\details below) when I tried to use igraph library in my Xubuntu VM. This problem did not happen before . Everything was working just fine.
It started very recently when I was trying to re-set-up R\igraph in another new VM(Xubuntu) of mine.
Can anybody give me any kind of advice regarding how to fix this problem?
Below are the Details -
Error Message -
Attaching package: ‘igraph’
The following objects are masked from ‘package:stats’:
decompose, spectrum
The following object is masked from ‘package:base’:
union
Loading required package: methods
Attaching package: ‘igraph’
The following objects are masked from ‘package:stats’:
decompose, spectrum
The following object is masked from ‘package:base’:
union
How I installed R Base & Igraph -
sudo apt-get -y install r-base
sudo echo "r <- getOption('repos'); r['CRAN'] <- 'http://cran.us.r- project.org'; options(repos = r);" > ~/.Rprofile
sudo Rscript -e "install.packages('ggplot2')"
sudo Rscript -e "install.packages('plyr')"
sudo Rscript -e "install.packages('reshape2')"
sudo Rscript -e "install.packages('igraph')"
sudo Rscript -e "install.packages('doBy')"
sudo Rscript -e "install.packages('stargazer')"
My R - Program
library(igraph)
g <- read.graph("DataForImage.net", format="pajek")
g <- delete.vertices(g,which(degree(g)<1))
jpeg(filename = "Image1.jpg", width = 2000, height = 2000,
units = "px", pointsize = 10, bg = "white",
res = NA)
g <- simplify(g)
l <- layout.fruchterman.reingold(g, dim=2,verbose=TRUE)
l <- layout.norm(l, -1,1, -1,1)
fcs <- fastgreedy.community(simplify(as.undirected(g)))
Q <- round(max(fcs$modularity), 3)
fcs <- community.to.membership(g, fcs$merges, steps=which.max(fcs$modularity)-1 )
plot(g, layout=l,vertex.shape="circle", vertex.size=2, vertex.label=NA, vertex.color="black",
vertex.frame.color="black", edge.width=5,
rescale=FALSE, xlim=range(l[,1]), ylim=range(l[,2]),
main="")
results <- read.table("detailTotals.csv", header=TRUE, sep=",")
jpeg(filename = "Image2.jpg", width = 2000, height = 2000,
units = "px", pointsize = 50, bg = "white",
res = NA)
plot(results$SetLineTotal, results$SetCount, main="Set Analysis",
xlab="Set Lines", ylab="Set Counts", col="black", bg="black", pch=21, cex=1)
grid(nx = 50, ny = 50, col = "lightgray", lty = "dotted", lwd = par("lwd"), equilogs = TRUE)
I thought I will share the final solution that seems to work for me.
I digged down a bit and upon some analysis , I found out the below.
The error seems to be with the igraph version - V1.0. The code statement in above R - program
l <- layout.fruchterman.reingold(g, dim=2,verbose=TRUE)
errors out in igraph V1.0.
The R-igraph package is re-written - and thereby some of the functions\network algorithms from older version is replaced\re-coded\modified in newer igraph version - 1.0 onwards.
So I reverted back to an older igraph package (0.7.1) and now I am no more facing the issue. And my R-program seems to work fine.
Below are the commands to revert to an older igraph package 0.7.1
wget http://cran.r-project.org/src/contrib/Archive/igraph/igraph_0.7.1.tar.gz
sudo R CMD INSTALL igraph_0.7.1.tar.gz

Python 3.3:cx_freeze & pyserial: cannot import traceback module

I'm newbie in cx_freeze. I'm triing to make an executable from python 3.3 script that uses "time", "serial" and "tkinter".
Cx_freeze run without any errors, but starting the exe file is resulting with error:
cannot import traceback module
Exception: No module named 're'
Original Exception: No module named 'serial'
I have this setup.py of cx_freeze
from cx_Freeze import setup, Executable
includes = ["serial", "tkinter"]
excludes = []
packages = []
path = []
GUI2Exe_Target_1 = Executable(
# what to build
script ='test6.1.py',
initScript = None,
base = 'Win32GUI',
targetDir = r"dist",
targetName = "bludiste2.exe",
compress = True,
copyDependentFiles = True,
appendScriptToExe = False,
appendScriptToLibrary = False,
icon = None
)
Does anyone know, how to solve it, please?
Thank you.
The first two lines are a bug that will be fixed in the next version of cx_Freeze. If you stick an import re in your script, you'll see the correct error message.
The last line is your real problem - that means it didn't find the serial module when you froze it. Check where pyserial is installed on your computer.

Resources