gdbm error 22 when performing Python shelve open - python-3.x

Doing a simple shelve.open will give the following error:
>>> shelve.open('foo')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.6/shelve.py", line 243, in open
return DbfilenameShelf(filename, flag, protocol, writeback)
File "/usr/lib/python3.6/shelve.py", line 227, in __init__
Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback)
File "/usr/lib/python3.6/dbm/__init__.py", line 94, in open
return mod.open(file, flag, mode)
_gdbm.error: [Errno 22] Invalid argument
I've only come across one related search result to this issue: https://github.com/pydanny/cookiecutter-django/issues/1793#issuecomment-440406112
I got exactly the same error on a Vagrant dev environment. Celery uses dbm for persistent storage, which is built on top of the gdbm C library. Some testing has revealed that this works when creating or opening files on a native filesystem but not on a mounted filesystem.
I'm running this under a Vagrant Ubuntu box in MacOS so it makes sense. I have also run the same box under Windows 10 and this issue doesn't crop up. Any clues for a fix?

I had the same issue and couldn't find any help online until I came across this post
https://github.com/we45/ThreatPlaybook/issues/11
creating a new virtual environment worked for me

Related

ffmpeg-python wrapper ffmpeg.run() getting FILENOTFOUNDERROR

I'm trying to figure out and learn how to use the ffmpeg-python wrapper and am getting a file not found error. both the mp4 file I'm trying to process and the python file are both in a folder on my desktop. I'm not sure if I'm using it correctly here.
I'm running windows 10 32bit, python 3.6 and have ffmpeg-python 0.16.0 installed. Is there additional packages I need installed in order for this to work? I tried the same code on my 64 bit windows 10 desktop and got the same error.
import ffmpeg
videoInput = ffmpeg.input('vid.mp4')
videoOutput = videoInput.output('test.avi')
videoOutput.run()
This is the error that I get in python shell
Traceback (most recent call last):
File "C:\Users\geral\Desktop\PythonPrograms\ffmpegexample.py", line 7, in <module>
videoOutput.run()
File "C:\Users\geral\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ffmpeg\_run.py", line 300, in run
overwrite_output=overwrite_output,
File "C:\Users\geral\AppData\Local\Programs\Python\Python36-32\lib\site-packages\ffmpeg\_run.py", line 272, in run_async
args, stdin=stdin_stream, stdout=stdout_stream, stderr=stderr_stream)
File "C:\Users\geral\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "C:\Users\geral\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 997, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
Well I figured it out and it was actually really quite simple. Hopefully this will help anyone who is new to ffmpeg or ffmpeg-python.
After reading through the traceback: Probably 100 times. I realised that ffmpeg probably wasn't packaged with ffmpeg-python and I never installed ffmpeg myself. So I simply installed ffmpeg using This Installation Guide and everything worked.
I Probably have this memorised by now, Ive read it enough times.
ffmpeg-python API Reference
So Long story short you must have ffmpeg installed before ffmpeg-python will work.

repo fail to init on Ubuntu 16,0 virtual box on Macbook

I am trying to build AOSP image on my mac Book using Linux virtual box.
Since I don't have enough space on Mac I am trying to checkoutAOSP on external 2 TB Segate HDD which I planned to use for build.
I have installed repo tool and python 2.7 but when I try to init repo with this command
repo init -u https://android.googlesource.com/platform/manifest
It fail with this error message
hitesh#hitesh-VirtualBox:/media/hitesh/2TB/test$ repo init -u https://android.googlesource.com/platform/manifest
Get https://android.googlesource.com/platform/manifest
Traceback (most recent call last):
File "/media/hitesh/2TB/test/.repo/repo/main.py", line 531, in <module>
_Main(sys.argv[1:])
File "/media/hitesh/2TB/test/.repo/repo/main.py", line 507, in _Main
result = repo._Run(argv) or 0
File "/media/hitesh/2TB/test/.repo/repo/main.py", line 180, in _Run
result = cmd.Execute(copts, cargs)
File "/media/hitesh/2TB/test/.repo/repo/subcmds/init.py", line 399, in Execute
self._SyncManifest(opt)
File "/media/hitesh/2TB/test/.repo/repo/subcmds/init.py", line 171, in _SyncManifest
m._InitGitDir(mirror_git=mirrored_manifest_git)
File "/media/hitesh/2TB/test/.repo/repo/project.py", line 2292, in _InitGitDir
self._UpdateHooks()
File "/media/hitesh/2TB/test/.repo/repo/project.py", line 2312, in _UpdateHooks
self._InitHooks()
File "/media/hitesh/2TB/test/.repo/repo/project.py", line 2341, in _InitHooks
os.symlink(os.path.relpath(stock_hook, os.path.dirname(dst)), dst)
OSError: [Errno 38] Function not implemented
I dont know how to trouble shoot this, I dont understand which function is not implemented,
The repo needs python2, you can first check your python version of Linux is python2 not python3.
I figured it out repo cant be initialise on an external hdd. I had to create a vdi file on my external hard disk and then use that to download aosp source code.

Reading .doc files in python on windows 10

Note: This was flagged as a potential duplicate of this, but the point of my question is that using textract doesn't work. I am looking either for (a) a way to get textract to work on windows 10 or (b) an alternate solution.
I am building a system that needs to read various types of files. I have set up pdfminer to read the .pdfs, and based on the process outlined here I installed textract, and I can now also read .docx files. However textract relies on antiword for reading .doc files and I cannot get this to work, even after following the directions here I could not find and install a working version of antiword. I do not have microsoft word installed on my machine, and I am running windows 10 with python 3.6.5. Is there any other way to read .doc files?
Here is the bug when running textract.process('d.doc') (ignore the first error, the file is definitely there):
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\textract\parsers\utils.py", line 84, in run
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 997, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\ProgramData\Anaconda3\lib\site-packages\textract\parsers\__init__.py", line 77, in process
return parser.process(filename, encoding, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\textract\parsers\utils.py", line 46, in process
byte_string = self.extract(filename, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\textract\parsers\doc_parser.py", line 9, in extract
stdout, stderr = self.run(['antiword', filename])
File "C:\ProgramData\Anaconda3\lib\site-packages\textract\parsers\utils.py", line 91, in run
' '.join(args), 127, '', '',
textract.exceptions.ShellError: The command antiword d.doc failed with exit code 127
From the 'Windows installation problem' series: https://github.com/deanmalmgren/textract/issues/194#issuecomment-507243521
After following the steps to 'install' antiword, I was facing the same problem as yours.
Restarting windows after setting up the environment path variable entirely solved this exact error message for me. (This was the last error I was facing for handling .doc files with textract)
Installation instructions extracted from https://github.com/deanmalmgren/textract/issues/194#issuecomment-506065817
"Install Antiword
(I followed Reading .doc file in Python using antiword in Windows (also .docx))
Go to https://www.softpedia.com/get/Office-tools/Other-Office-Tools/Antiword.shtml
Extract to c:\antiword (yes it's required to be in the root directory)
Add location to path like we did tesseract-ocr [basically add c:\antiword to the system path (environment variable)]"
I was able to get part of the text using olefile, but olefile ultimately only handles bytes and does not handle the encoding of Word .doc files. The solution is to use LibreOffice, see my other question here

MoviePy Error: The system cannot find the file specified

I'm getting the error in the title when trying to run the example code below on Windows 10/Python 3.6.1/Sublime Text Editor 3. I made sure to set my MAGICK_HOME environment variable to point to where I manually installed ImageMagick. I made sure to only have 1 version of ImageMagick installed. I made sure FFMPEG, Numpy, imageio, Decorator, and tqdm were all installed.
Yes, the file "vidclip.mp4" exists. The desired behavior here is to simply clip the video and add text to the center as per the example on the github page, i.e. to simply run the code successfully.
Does anyone know what might be wrong?
Example code from github:
from moviepy.editor import *
video = VideoFileClip("vidclip.mp4").subclip(7,64)
# Make the text. Many more options are available.
txt_clip = ( TextClip("Ken Block who?",fontsize=70,color='white')
.set_position('center')
.set_duration(10) )
result = CompositeVideoClip([video, txt_clip]) # Overlay text on video
result.write_videofile("vidclip_edited.webm",fps=25) # Many options...
The full error trace:
Traceback (most recent call last):
File "C:\Users\av\AppData\Local\Programs\Python\Python36\lib\site-packages\moviepy\video\VideoClip.py", line 1220, in __init__
subprocess_call(cmd, verbose=False )
File "C:\Users\av\AppData\Local\Programs\Python\Python36\lib\site-packages\moviepy\tools.py", line 42, in subprocess_call
proc = sp.Popen(cmd, **popen_params)
File "C:\Users\av\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "C:\Users\av\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 990, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\av\Desktop\Desktop\Projects\Youtube\blender\test\testMoviePy.py", line 6, in <module>
txt_clip = ( TextClip("Ken Block who?",fontsize=70,color='white')
File "C:\Users\av\AppData\Local\Programs\Python\Python36\lib\site-packages\moviepy\video\VideoClip.py", line 1229, in __init__
raise IOError(error)
OSError: MoviePy Error: creation of None failed because of the following error:
[WinError 2] The system cannot find the file specified.
.This error can be due to the fact that ImageMagick is not installed on your computer, or (for Windows users) that you didn't specify the path to the ImageMagick binary in file conf.py, or.that the path you specified is incorrect
Found the problem. I didn't realize it was imperative that I specify the location of ffmpeg.exe and convert.exe within ImageMagick's config_defaults.py file. After that, I install MoviePy (in that order).

Error in using pyexiv2 metadata.read() method

I am trying to follow the tutorials in the pyexiv2 tutorials page
But due to some unknown reasons, it refuses to run, and I thought of seeking some advice from you.
`#this is my code
import pyexiv2
metadata = pyexiv2.ImageMetadata('test.png')
metadata.read()`
when I try to run this code in the terminal, with the python interpreter, in the folder which contains the image, 'test.png', following error is given.
`Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/pyexiv2/metadata.py", line 107,
in read
self.__image = self._instantiate_image(self.filename)
File "/usr/lib/python2.7/dist-packages/pyexiv2/metadata.py", line 74,
in
_instantiate_image
raise IOError(ENOENT, os.strerror(ENOENT), filename)
IOError: [Errno 2] No such file or directory: 'test.png'
`
This is my setup. I am running ubuntu 16.04LTS on virtual machine on a Mac book, with macOS sierra. Python version is 2.7.12.
I used this guide to install pyexiv2. when I inspect the /usr/local/lib folder, it shows that the libexiv2 is installed there.
What am I doing wrong here? and is there a better version of pyexiv2 to use?
I am fairly new to using python.:) and thanks in advance
This can be solved in two ways
1) Copy the file test.png in the same directory you have your python file with the code.
2) Provide a complete path. If, for example, you have test.png on your desktop, replace
metadata = pyexiv2.ImageMetadata('test.png')
with
metadata = pyexiv2.ImageMetadata('C:\\Users\\MYUSERPROFILENAME\\Desktop\\test.jpg')
where MYUSERPROFILENAME is your user profile. Hope this helps

Resources