OSError: libmediainfo.so.0: cannot open shared object file: No such file or directory from aws lambda - amazon-web-services

I am using pymediainfo in lambda function , and I have followed the answer from this so question .
The function has the below code
from pymediainfo import MediaInfo
s3_bucket_file_key = 'https://s3-region.amazonaws.com/sample-bucket/sample_video.mov'
media_info = MediaInfo.parse(s3_bucket_file_key)
media_info_json = media_info.to_json()
Can someone please help me , the sample bucket is public , and I can run this code on my system . but getting the below error from Cloudwatch in aws-lambda.
It seems like libmediainfo is a os related package, I am not sure how to export it to the python deployment package.
anupam:Videos$ apt-cache search libmediainfo
libmediainfo-dev - library reading metadata from media files -- headers
libmediainfo-doc - library for reading metadata from media files -- documentation
libmediainfo0v5 - library for reading metadata from media files -- shared library
error
libmediainfo.so.0: cannot open shared object file: No such file or directory: OSError
Traceback (most recent call last):
File "/var/task/lambda_function.py", line 166, in lambda_handler
media_info = MediaInfo.parse(key)
File "/var/task/pymediainfo/__init__.py", line 183, in parse
lib = cls._get_library(library_file)
File "/var/task/pymediainfo/__init__.py", line 155, in _get_library
return CDLL("libmediainfo.so.0")
File "/usr/lib64/python2.7/ctypes/__init__.py", line 357, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libmediainfo.so.0: cannot open shared object file: No such file or directory
When I added libmediainfo.so.0 manually to the command
media_info = MediaInfo(video_file, library_file='path/to/libmediainfo')
I am getting the below error now for libzen.so.0
libzen.so.0: cannot open shared object file: No such file or directory: OSError
Traceback (most recent call last):
File "/var/task/erlabs.py", line 166, in lambda_handler
media_info = MediaInfo.parse(key,library_file='libmediainfo.so.0')
File "/var/task/pymediainfo/__init__.py", line 183, in parse
lib = cls._get_library(library_file)
File "/var/task/pymediainfo/__init__.py", line 146, in _get_library
return CDLL(library_file)
File "/usr/lib64/python2.7/ctypes/__init__.py", line 357, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libzen.so.0: cannot open shared object file: No such file or directory

Related

unable to from Convert Pascal VOC to tfrecords for tensor flow object detection API

unable to from Convert Pascal VOC to tfrecords for tensor flow object detection API , reference : https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/training.html#create-tensorflow-records
!python /workspace/scripts/generate_tfrecord1.py -x /workspace/kitti_dataset/training -l /workspace/annotations/label_map.pbtxt -o /workspace/annotations/train.record
!python /workspace/scripts/generate_tfrecord1.py -x /workspace/kitti_dataset/validation -l /workspace/annotations/label_map.pbtxt -o /workspace/annotations/train.record
error that I am getting :
/usr/local/lib/python3.8/dist-packages/tensorflow_io/python/ops/__init__.py:98: UserWarning: unable to load libtensorflow_io_plugins.so: unable to open file: libtensorflow_io_plugins.so, from paths: ['/usr/local/lib/python3.8/dist-packages/tensorflow_io/python/ops/libtensorflow_io_plugins.so']
caused by: ['/usr/local/lib/python3.8/dist-packages/tensorflow_io/python/ops/libtensorflow_io_plugins.so: undefined symbol: _ZN3tsl5mutexC1Ev']
warnings.warn(f"unable to load libtensorflow_io_plugins.so: {e}")
/usr/local/lib/python3.8/dist-packages/tensorflow_io/python/ops/__init__.py:104: UserWarning: file system plugins are not loaded: unable to open file: libtensorflow_io.so, from paths: ['/usr/local/lib/python3.8/dist-packages/tensorflow_io/python/ops/libtensorflow_io.so']
caused by: ['/usr/local/lib/python3.8/dist-packages/tensorflow_io/python/ops/libtensorflow_io.so: undefined symbol: _ZNK10tensorflow4data11DatasetBase8FinalizeEPNS_15OpKernelContextESt8functionIFN3tsl8StatusOrISt10unique_ptrIS1_NS5_4core15RefCountDeleterEEEEvEE']
warnings.warn(f"file system plugins are not loaded: {e}")
Traceback (most recent call last):
File "/workspace/scripts/generate_tfrecord1.py", line 172, in <module>
tf.app.run()
File "/usr/local/lib/python3.8/dist-packages/tensorflow/python/platform/app.py", line 36, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "/usr/local/lib/python3.8/dist-packages/absl/app.py", line 312, in run
_run_main(main, args)
File "/usr/local/lib/python3.8/dist-packages/absl/app.py", line 258, in _run_main
sys.exit(main(argv))
File "/workspace/scripts/generate_tfrecord1.py", line 159, in main
examples = xml_to_csv(args.xml_dir)
File "/workspace/scripts/generate_tfrecord1.py", line 92, in xml_to_csv
int(bndbox.find('xmin').text),
ValueError: invalid literal for int() with base 10: '\n 692.09\n '
/usr/local/lib/python3.8/dist-packages/tensorflow_io/python/ops/__init__.py:98: UserWarning: unable to load libtensorflow_io_plugins.so: unable to open file: libtensorflow_io_plugins.so, from paths: ['/usr/local/lib/python3.8/dist-packages/tensorflow_io/python/ops/libtensorflow_io_plugins.so']
caused by: ['/usr/local/lib/python3.8/dist-packages/tensorflow_io/python/ops/libtensorflow_io_plugins.so: undefined symbol: _ZN3tsl5mutexC1Ev']
warnings.warn(f"unable to load libtensorflow_io_plugins.so: {e}")
/usr/local/lib/python3.8/dist-packages/tensorflow_io/python/ops/__init__.py:104: UserWarning: file system plugins are not loaded: unable to open file: libtensorflow_io.so, from paths: ['/usr/local/lib/python3.8/dist-packages/tensorflow_io/python/ops/libtensorflow_io.so']
caused by: ['/usr/local/lib/python3.8/dist-packages/tensorflow_io/python/ops/libtensorflow_io.so: undefined symbol: _ZNK10tensorflow4data11DatasetBase8FinalizeEPNS_15OpKernelContextESt8functionIFN3tsl8StatusOrISt10unique_ptrIS1_NS5_4core15RefCountDeleterEEEEvEE']
warnings.warn(f"file system plugins are not loaded: {e}")
Traceback (most recent call last):
File "/workspace/scripts/generate_tfrecord1.py", line 172, in <module>
tf.app.run()
File "/usr/local/lib/python3.8/dist-packages/tensorflow/python/platform/app.py", line 36, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "/usr/local/lib/python3.8/dist-packages/absl/app.py", line 312, in run
_run_main(main, args)
File "/usr/local/lib/python3.8/dist-packages/absl/app.py", line 258, in _run_main
sys.exit(main(argv))
File "/workspace/scripts/generate_tfrecord1.py", line 159, in main
examples = xml_to_csv(args.xml_dir)
File "/workspace/scripts/generate_tfrecord1.py", line 92, in xml_to_csv
int(bndbox.find('xmin').text),
ValueError: invalid literal for int() with base 10: '583.43'
unable to from Convert Pascal VOC to tfrecords for tensor flow object detection API training
The cause is that you have renamed the image after labeling, causing the image name (.jpg) and label file name (.XML) to not match, resulting in the name in the image and CSV file not matching.
The solution is to create the script to rename the XML file.
and then exported to CSV again

Creating folders on the BeagleBone Black in Python

I have code in Pyhton(2.7) on a beagle bone black to create folders that I copy fills of data to. These folders are mounted to the micro-Sd card(archive) and a thumb drive(live data copy). The file is being made in my working dir.
Code:
#staticmethod # Creates a folder if not present
def create_folder(folder_name):
directory = os.path.dirname(folder_name)
try:
os.path.exists(directory)
print("Folder failed")
except:
os.makedirs(directory, 0o777)
print("Folder created")
Error:
Traceback (most recent call last):
File "/var/lib/cloud9/TEMS_Operations/System_Files.py", line 125, in <module>
temp.create_folder(temp.main_folder)
File "/var/lib/cloud9/TEMS_Operations/System_Files.py", line 41, in create_folder
directory = os.path.dirname(folder_name)
File "/usr/lib/python2.7/posixpath.py", line 122, in dirname
i = p.rfind('/') + 1
AttributeError: 'function' object has no attribute 'rfind'
Any Suggestions?
Test program:
def test(self): # System file test
name1 = self.alarm_file()
print(name1)
name2 = self.data_file()
print(name2)
name3 = self.main_folder()
print(name3)
name4 = self.arch_folder()
print(name4)
self.create_data_file(name2)
self.create_alarm_file(name1)
self.create_folder(name3)
self.create_folder(name4)
file_to = name3 + name1
file_from = mane4 +name1
self.copyfile(file_from, file_to)
temp = SystemFiles("ZapOFS", "ZapLab")
print(os.getcwd())
temp.test()
Errors:
/media/mmc/2019/1
/media/usb/2019/1
File created
File created
<type 'str'>
Folder failed
<type 'str'>
Folder failed
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/ikpdb.py", line 1866, in main
ikpdb._runscript(mainpyfile)
File "/usr/local/lib/python2.7/dist-packages/ikpdb.py", line 1415, in _runscript
exec(statement, globals, locals)
File "<string>", line 1, in <module>
File "/var/lib/cloud9/TEMS_Operations/System_Files.py", line 132, in <module>
temp.test()
File "/var/lib/cloud9/TEMS_Operations/System_Files.py", line 127, in test
copyfile(file_from, file_to)
File "/usr/lib/python2.7/shutil.py", line 82, in copyfile
with open(src, 'rb') as fsrc:
IOError: [Errno 2] No such file or directory: '/media/usb/2019/1ZapOFS_ZapLab_Alarm_File_2019_1.csv'
[IKPdb-g] 16:34:52,604104 - INFO - Uncaught exception. Entering post mortem debugging
The only way to allow the creation of folders in python on the mounted MMC and/or USB drives on the BeagleBone black is to remove the sudo password for the current users and add -rw permissions for the program.
# sudo echo "debian ALL=NOPASSWD: ALL" >>/etc/sudoers
Not what I was hoping for, but the only way i can find.
https://elinux.org/Beagleboard:BeagleBoneBlack_Debian

ERAlchemy cannot connect to database

I don't understand the syntax to call the render feature of ERAlchemy (https://pypi.org/project/ERAlchemy see "Usage for Python"). I am using Python 2.7, sqlite3, and PyCharm. I have ERAlchemy, GraphViz, and PyGraphViz installed.
I am trying the following, but it cannot connect to the database:
from eralchemy import render_er
render_er("sqlite:///C:\\Users\\myname\\Documents\\Work\\pythonsqlite.db", 'erd_from_sqlite.png')
And this is the error:
Traceback (most recent call last):
File "C:/Users/myname/Documents/Work/_sql_functions_rev0.py", line 81, in <module>
render_er("sqlite:///C:\\Users\\myname\\Documents\\Work\\pythonsqlite.db", 'erd_from_sqlite.png')
File "C:\Python27\ArcGISx6410.6\lib\site-packages\eralchemy\main.py", line 236, in render_er
intermediary_to_output(tables, relationships, output)
File "C:\Python27\ArcGISx6410.6\lib\site-packages\eralchemy\main.py", line 75, in intermediary_to_schema
graph.draw(path=output, prog='dot', format=extension)
File "C:\Python27\ArcGISx6410.6\lib\site-packages\pygraphviz\agraph.py", line 1474, in draw
data = self._run_prog(prog, args)
File "C:\Python27\ArcGISx6410.6\lib\site-packages\pygraphviz\agraph.py", line 1308, in _run_prog
runprog = r'"%s"' % self._get_prog(prog)
File "C:\Python27\ArcGISx6410.6\lib\site-packages\pygraphviz\agraph.py", line 1295, in _get_prog
raise ValueError("Program %s not found in path." % prog)
ValueError: Program dot not found in path.
Ah! Found the answer here
had to find the folder with "dot.exe" and add it to the environment variables -> system variables -> path

Unable to copy files of certain extension in Python using loop

I want to loop through the files present in Audio_files folder and check if it is raw file or wave file and put it in the respective directories.
Here is my code:
import shutil
import os
source = os.listdir("/home/GM/codec_implement/Audio_files/")
destination = "/home/GM/codec_implement/raw_files/"
destination2 = "/home/GM/codec_implement/raw_files/wave_files/"
for files in source:
if files.endswith(".wav"):
shutil.copy(files,destination)
elif files.endswith(".raw"):
shutil.copy(files,destination)
else:
print "Invalid format"
Please let me know where I am making mistake. Error i get is:
Traceback (most recent call last): File "./checkaudiofiles.py", line
12, in shutil.copy(files,destination) File
"/usr/lib/python2.7/shutil.py", line 119, in copy copyfile(src, dst)
File "/usr/lib/python2.7/shutil.py", line 82, in copyfile with
open(src, 'rb') as fsrc: IOError: [Errno 2] No such file or directory:
'test_sound.wav'
The error means that the test_sound.wav file is not on that directory. These file might be removed between the two proces or the os.listdir() and the shutil.copy() don't list the files the same way.

how to use envoy package in python?

I have installed package envoy. I ran the script but a windows error occured .I commented envoy.run then the full script runs but when I remove the comment, error occurs.
import envoy
# This data is checked-in to the repository and is a compressed
# version of the output from Example 3
F = 'resources/ch06-mailboxes/data/enron.mbox.json.bz2'
r = envoy.run("bunzip2 %s" % (F,))
print r.std_out
print r.std_err
traceback of script:
Exception in thread Thread-9:
Traceback (most recent call last):
File "C:\Users\sachin\Anaconda\lib\threading.py", line 810, in __bootstrap_inner
self.run()
File "C:\Users\sachin\Anaconda\lib\threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "C:\Users\sachin\Anaconda\lib\site-packages\envoy\core.py", line 40, in target
bufsize=0,
File "C:\Users\sachin\Anaconda\lib\subprocess.py", line 709, in __init__
errread, errwrite)
File "C:\Users\sachin\Anaconda\lib\subprocess.py", line 957, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
Please try this:
F = os.path.join(os.getcwd(), 'resources/ch06-mailboxes/data/enron.mbox.json.bz2')