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
Related
I am trying to use the Kaggle API to extract data from the kaggle website. I am using Ubuntu 18.04. When I enter the following command:
kaggle competitions download -c home-credit-default-risk
I get the following error:
Traceback (most recent call last):
File "/home/hduser/anaconda3/bin/kaggle", line 5, in <module>
from kaggle.cli import main
File "/home/hduser/anaconda3/lib/python3.7/site-packages/kaggle/__init__.py", line 23, in <module>
api.authenticate()
File "/home/hduser/anaconda3/lib/python3.7/site-packages/kaggle/api/kaggle_api_extended.py", line 149, in authenticate
self.config_file, self.config_dir))
OSError: Could not find kaggle.json. Make sure it's located in /home/hduser/.kaggle/kaggle.json. Or use the environment method.
This is strange because I have the kaggle.json file saved in the correct directory and I have all permissions granted for it.
ls ~/.kaggle
returns:
kaggle.json
Am I missing something here?
I had the same problem.
Using Google's GCP notebook and after several attempts, I managed to resolve it as follows:
Generate the API file (JSON) through the Kaggle platform.
Execute:
https://adityashrm21.github.io/Setting-Up-Kaggle/
I have solved this. For some reason the following command works and not the one posted above.
~/.local/bin/kaggle competitions download -c home-credit-default-risk
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
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.
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
being a few weeks old coder,I am unable to make python read my file despite the code and .txt file being in the same folder
highest_score=0
result_f = open("results.text")
for line in result_f:
if float (line)>highest_score:
highest_score = float(line)
result_f.close()
print("the highest score:")
print(highest_score)
and result is
Traceback (most recent call last):
File "C:\Python33\-mu.py", line 2, in <module>
result_f = open("results.text")
FileNotFoundError: [Errno 2] No such file or directory: 'results.text'
Please help
Basically you are trying to open the file result.text. The error returned is that Python Idle cannot find that file. I notice that you mentioned a .txt file but in your code you try to open a .text file.
So I would suggest you to check wheter your file extension is .txt or .text and, in case, correct.
If the error still persists, try to give the full path to the open command. For example:
result_f = open("/Users/Joe/Desktop/results.text")
Both Windows and Mac OS give, somewhere when right-clicking on the file, the full path (among other information).
I faced a similar issue, where I was trying to read a file in idle but it couldn't find the path. What worked for me:
Enter the full path of the file with the extension
Instead of the native path writing style in windows i.e. (D:\python\sample.txt)
use (D:/python/sample.txt)
It worked out for me in Windows 7, IDLE 3.6.4 and also works on Windows 8