Fixing subprocess.py file Error: File not found? [duplicate] - python

This question already has answers here:
What exactly is current working directory?
(5 answers)
Closed 27 days ago.
I am using a python package from Gray Arrow's Dejavu. I have installed all the required dependencies and other packages necessary to run my code. When running the following code:
import warnings
import json
warnings.filterwarnings("ignore")
from dejavu import Dejavu
from dejavu.recognize import FileRecognizer
with open('dejavu.cnf') as f:
config = json.load(f)
djv = Dejavu(config)
djv.fingerprint_file('mp3/Sean-Fournier--Falling-For-You.mp3')
song = djv.recognize(FileRecognizer, 'mp3/Sean-Fournier--Falling-For-
You.mp3')
print("from file recognized: {}\n".format(song))
I receive the following errors:
Traceback (most recent call last):
File "testing.py", line 13, in <module>
djv.fingerprint_file('mp3/Sean-Fournier--Falling-For-You.mp3')
File "D:\dejavu-master\dejavu\__init__.py", line 109, in
fingerprint_file song_name=song_name
File "D:\dejavu-master\dejavu\__init__.py", line 182, in
_fingerprint_worker channels, Fs, file_hash = decoder.read(filename,
limit)
File "D:\dejavu-master\dejavu\decoder.py", line 51, in read
audiofile = AudioSegment.from_file(filename)
File "C:\Program Files\Python37\lib\site-
packages\pydub\audio_segment.py", line 665, in from_file info =
mediainfo_json(orig_file)
File "C:\Program Files\Python37\lib\site-packages\pydub\utils.py",
line 263, in mediainfo_json res = Popen(command,
stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
File "C:\Program Files\Python37\lib\subprocess.py", line 775, in
__init__ restore_signals, start_new_session)
File "C:\Program Files\Python37\lib\subprocess.py", line 1178, in
_execute_child startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file
specified
I have done complete re-installations of python 3.7 and all of the packages and dependencies to attempt correction of this problem.
I do not understand what file cannot be found and have done research in hopes to find an answer to this issue. I truly appreciate any help and knowledge that can be shared with me on this topic.

Try and place "Sean-Fournier--Falling-For-You.mp3" file in the exact directory you have your script, I don't think the folder reference to the mp3 folder is being handled correctly :)
djv.fingerprint_file('mp3/Sean-Fournier--Falling-For-You.mp3')
song = djv.recognize(FileRecognizer, 'mp3/Sean-Fournier--Falling-For-
You.mp3')

Related

executable generated from pyinstaller it's not working

I'm doing a program responsible for managing a bookstore and I'm at the end of it. I'm creating the executable from it, but it's giving an error when running I don't know what it is.
Error:
Traceback (most recent call last):
File "main.py", line 3494, in <module>
File "db_manager.py", line 278, in titulo_livros
File "pandas\io\parsers.py", line 605, in read_csv
File "pandas\io\parsers.py", line 457, in _read
File "pandas\io\parsers.py", line 814, in __init__
File "pandas\io\parsers.py", line 1045, in _make_engine
File "pandas\io\parsers.py", line 1862, in __init__
File "pandas\io\parsers.py", line 1357, in _open_handles
File "pandas\io\common.py", line 642, in get_handle
FileNotFoundError: [Errno 2] No such file or directory: 'livros.csv'
[432] Failed to execute script main
The command I am using to generate the exe file is "pyinstaller --onefile main.py".
And that is my tree folder:
my tree folder project
Please help me, i have no idea of what is going on.
Thank you very much in advance.
somewhere you are doing pandas.read_csv(fname) where fname='livros.csv'
you need to give it the right path to the csv (or bundle the csv into the executable ... but that probably doesnt make sense, im not sure why you would ever bundle the csv into the executable)
after alot of back and forth I think this is what you want
import os
import pandas
import sqlalchemy
from sqlalchemy import create_engine
db_path = os.path.expanduser('~/my_file.db')
engine = create_engine('sqlite:///'+db_path, echo=False)
try:
existing = pandas.read_sql('SELECT title, author FROM books', engine)
except:
existing = pandas.DataFrame({'title':['Title 1','Title 2'],'author':['Bob Roberts','Sam Spade']})
print("DBPATH:",db_path)
# ... do some stuff (add/edit/remove items from your dataframe)
existing.to_sql("books",engine)

How to merge audio and video file using ffmpeg in python?

I need to merge both audio and video using ffmpeg in python 3.7,could you help me to solve this issue?
Here i used code :
from pathlib import Path
glob_path = Path(r"D:\t")
file_name = [str(pp) for pp in glob_path.glob(r'**/*.mp4')]
print(file_name)
video_stream = ffmpeg.input(file_name[0])
audio_stream = ffmpeg.input(file_name[1])
print(video_stream)
print(audio_stream)
ffmpeg.output(audio_stream, video_stream, 'out.mp4').run()
I getting this out put error
['D:\\t\\audio.mp4', 'D:\\t\\video.mp4']
input(filename='D:\\t\\audio.mp4')[None] <b0ebefda3dca>
input(filename='D:\\t\\video.mp4')[None] <388c87446fd1>
Traceback (most recent call last):
File "C:\Users\LENOVO\PycharmProjects\calc_new\udownlod.py", line 18, in <module>
ffmpeg.output(audio_stream, video_stream, 'out.mp4').run()
File "C:\Users\LENOVO\PycharmProjects\calc_new\venv\lib\site-packages\ffmpeg\_run.py", line 320, in run
overwrite_output=overwrite_output,
File "C:\Users\LENOVO\PycharmProjects\calc_new\venv\lib\site-packages\ffmpeg\_run.py", line 285, in run_async
args, stdin=stdin_stream, stdout=stdout_stream, stderr=stderr_stream
File "C:\Users\LENOVO\Anaconda3\lib\subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "C:\Users\LENOVO\Anaconda3\lib\subprocess.py", line 1178, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
Looks like one of the files cannot be found. The best thing to do is to check if both files exist at the specified locations.
FileNotFoundError: [WinError 2] The system cannot find the file specified
Even though it was shown path error, that error was in installation package, i used
conda install -c menpo ffmpeg
in https://anaconda.org/menpo/ffmpeg , solved my issue

Pydub, cannot locate mp3 file (OSError: [Errno 2] No such file or directory)

While trying to use an mp3 file in a python environment I get this error, my file directories are all properly spelt.
Note: the directories are formatted so that within a project folder there is the main code, and 2 sub-folders one for the non-altered mp3 files ("targets"), and one for the altered mp3 files ("altered_targets").
I have already tried to switch AudioSegment.from_file("filename","mp3") with no luck.
from pydub.playback import play
from pydub import AudioSegment
import sys
import os
sys.path.append('/usr/local/lib/python3.7/dist-packages/ffmpeg')
def adjust_volume(file_name, adjustment):
song = AudioSegment.from_mp3(file_name)
new_song = song + adjustment
new_title = "./alter_targets/%s" % (file_name)
new_song.export(new_title, format='mp3')
for target in os.listdir("./targets"):
adjust_volume("./targets/"+target, 10)
This code snippet should slightly increase the volume of the mp3 file within "targets", then save the new mp3 file into the "altered_targets" file.
Instead I get "OSError: [Errno 2] No such file or directory"
Traceback (most recent call last):
File "volume_alter.py", line 19, in <module>
adjust_volume("./targets/"+target, 10)
File "volume_alter.py", line 10, in adjust_volume
song = AudioSegment.from_mp3(file_name)
File "/usr/local/lib/python2.7/dist-packages/pydub/audio_segment.py", line 716, in from_mp3
return cls.from_file(file, 'mp3', parameters=parameters)
File "/usr/local/lib/python2.7/dist-packages/pydub/audio_segment.py", line 665, in from_file
info = mediainfo_json(orig_file)
File "/usr/local/lib/python2.7/dist-packages/pydub/utils.py", line 263, in mediainfo_json
res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
File "/usr/lib/python2.7/subprocess.py", line 394, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1047, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

Simple HTML to PDF python library error

I'm using this pydf to convert HTML to a PDF on our server. This is an example that comes right from their docs that illustrates the problem:
import pydf
pdf = pydf.generate_pdf('<h1>this is html</h1>')
with open('test_doc.pdf', 'wb') as f:
f.write(pdf)
When I go to run this file, I get the same error everytime:
(pdf) <computer>:<folder> <user>$ python pdf.py
Traceback (most recent call last):
File "pdf.py", line 3, in <module>
pdf = pydf.generate_pdf('<h1>this is html</h1>')
File "/Users/nilesbrandon/Projects/pdf/pdf/lib/python2.7/site-packages/pydf/wkhtmltopdf.py", line 121, in generate_pdf
return gen_pdf(html_file.name, cmd_args)
File "/Users/nilesbrandon/Projects/pdf/pdf/lib/python2.7/site-packages/pydf/wkhtmltopdf.py", line 105, in gen_pdf
_, stderr, returncode = execute_wk(*cmd_args)
File "/Users/nilesbrandon/Projects/pdf/pdf/lib/python2.7/site-packages/pydf/wkhtmltopdf.py", line 22, in execute_wk
p = subprocess.Popen(wk_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
I'm running this in a virtualenv and my pip freeze is only the following:
python-pdf==0.30
Any idea what could be going wrong here?
As you are using macOS, you need to download a wkhtmltopdf binary by your own:
pydf comes bundled with a wkhtmltopdf binary which will only work on Linux amd64 architectures. If you're on another OS or architecture your milage may vary, it is likely that you'll need to supply your own wkhtmltopdf binary and point pydf towards it by setting the WKHTMLTOPDF_PATH variable.

“git.exc.GitCommandNotFound: [WinError 2] The system cannot find the file specified” error in Python 3.5

I am trying to lemmatize a Latin text using Python 3.5 in Pycharm 5.0.4 with the CLTK library, but there seems to be a problem with Git. I get the error git.exc.GitCommandNotFound: [WinError 2] The system cannot find the file specified among other errors I believe are related—see below for the full output. I have tried adding a Git repository to the project folder and adding the git.exe path to version control but that seems to have done nothing. What can I do to get Git to work properly—please keep in mind that I am a complete neophyte when it comes to Python in particular and not very experienced with programming in general.
Code:
from cltk.stem.lemma import LemmaReplacer
from cltk.stem.latin.j_v import JVReplacer
from cltk.corpus.utils.importer import CorpusImporter
corpus_importer = CorpusImporter('latin')
corpus_importer.import_corpus('latin_text_latin_library')
corpus_importer.import_corpus('latin_models_cltk')
#corpus_importer.import_corpus('phi5', '~/PHI5/')
#t.convert_corpus(corpus='phi5')
j = JVReplacer()
lemmatizer = LemmaReplacer('latin')
In = open("CIC.txt","rt")
Out = open("CIC4.txt","wt")
text = In.read()
text = text.lower()
text = j.replace(text)
Out.write(str(lemmatizer.lemmatize(text)))
In.close()
Out.close()
Output:
C:\Users\Rune\AppData\Local\Programs\Python\Python35-32\python.exe "C:\Program Files (x86)\JetBrains\PyCharm 5.0.4\helpers\pydev\pydevd.py" --multiproc --qt-support --client 127.0.0.1 --port 58508 --file C:/Users/Rune/PycharmProjects/untitled/Pucker.py
pydev debugger: process 14648 is connecting
Connected to pydev debugger (build 143.1919)
--- Logging error ---
Traceback (most recent call last):
File "C:\Users\Rune\AppData\Local\Programs\Python\Python35-32\lib\site-packages\git\cmd.py", line 604, in execute
**subprocess_kwargs
File "C:\Users\Rune\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 950, in __init__
restore_signals, start_new_session)
File "C:\Users\Rune\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 1220, in _execute_child
startupinfo)
File "C:\Program Files (x86)\JetBrains\PyCharm 5.0.4\helpers\pydev\pydev_monkey.py", line 387, in new_CreateProcess
return getattr(_subprocess, original_name)(appName, patch_arg_str_win(commandLine), *args)
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\Rune\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cltk\corpus\utils\importer.py", line 134, in import_corpus
Repo.clone_from(git_uri, target_dir, depth=1)
File "C:\Users\Rune\AppData\Local\Programs\Python\Python35-32\lib\site-packages\git\repo\base.py", line 885, in clone_from
return cls._clone(git, url, to_path, GitCmdObjectDB, progress, **kwargs)
File "C:\Users\Rune\AppData\Local\Programs\Python\Python35-32\lib\site-packages\git\repo\base.py", line 826, in _clone
v=True, **add_progress(kwargs, git, progress))
File "C:\Users\Rune\AppData\Local\Programs\Python\Python35-32\lib\site-packages\git\cmd.py", line 450, in <lambda>
return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
File "C:\Users\Rune\AppData\Local\Programs\Python\Python35-32\lib\site-packages\git\cmd.py", line 878, in _call_process
return self.execute(make_call(), **_kwargs)
File "C:\Users\Rune\AppData\Local\Programs\Python\Python35-32\lib\site-packages\git\cmd.py", line 607, in execute
raise GitCommandNotFound(str(err))
git.exc.GitCommandNotFound: [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\Rune\AppData\Local\Programs\Python\Python35-32\lib\logging\__init__.py", line 980, in emit
msg = self.format(record)
File "C:\Users\Rune\AppData\Local\Programs\Python\Python35-32\lib\logging\__init__.py", line 830, in format
return fmt.format(record)
File "C:\Users\Rune\AppData\Local\Programs\Python\Python35-32\lib\logging\__init__.py", line 567, in format
record.message = record.getMessage()
File "C:\Users\Rune\AppData\Local\Programs\Python\Python35-32\lib\logging\__init__.py", line 330, in getMessage
msg = msg % self.args
TypeError: not enough arguments for format string
Call stack:
File "C:\Program Files (x86)\JetBrains\PyCharm 5.0.4\helpers\pydev\pydevd.py", line 2411, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\Program Files (x86)\JetBrains\PyCharm 5.0.4\helpers\pydev\pydevd.py", line 1802, in run
launch(file, globals, locals) # execute the script
File "C:\Program Files (x86)\JetBrains\PyCharm 5.0.4\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Users/Rune/PycharmProjects/untitled/Pucker.py", line 5, in <module>
corpus_importer.import_corpus('latin_text_latin_library')
File "C:\Users\Rune\AppData\Local\Programs\Python\Python35-32\lib\site-packages\cltk\corpus\utils\importer.py", line 136, in import_corpus
logger.error("Git clone of '%s' failed: '%s'", (git_uri, e))
Message: "Git clone of '%s' failed: '%s'"
Arguments: (('https://github.com/cltk/latin_text_latin_library.git', GitCommandNotFound('[WinError 2] The system cannot find the file specified',)),)
Process finished with exit code 0
You can manually download the corpus from https://github.com/cltk/latin_models_cltk and place it in the
~/cltk_data/latin/model/ folder (so ~/cltk_data/latin/model/latin_models_cltk/lemmata/ is an existing folder afterwards). Then you should be able to run the following just fine:
from cltk.stem.lemma import LemmaReplacer
LemmaReplacer('latin').lemmatize('some_latin_here')
For the same in Greek, just replace the 'latin' by 'greek' everywhere in these instructions. I imagine (but haven't tried) that it works the same for other languages too.
I am pretty sure that CLTK does not work with any Python version below 3.6, at least as of August 2017. I had a devil of a time getting 3.6 installed on Ubuntu (Ubuntu linus running dual boot from my PC laptop) but eventually got it to work. Also I specifically solved the problem that OP articulates above by following the instructions at https://disiectamembra.wordpress.com/2016/07/01/current-state-of-the-cltk-latin-lemmatizer/. Good luck!

Categories