Before enter data, I import a lib, but this lib give an error like this /
Warning (from warnings module): File
"C:\Users\Samuel\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pydub\utils.py",
line 165
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning) RuntimeWarning: Couldn't find ffmpeg or
avconv - defaulting to ffmpeg, but may not work
Warning (from warnings module): File
"C:\Users\Samuel\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pydub\utils.py",
line 179
warn("Couldn't find ffplay or avplay - defaulting to ffplay, but may not work", RuntimeWarning) RuntimeWarning: Couldn't find ffplay or
avplay - defaulting to ffplay, but may not work
TL;DR: As the source code indicates, you should install ffmpeg add it to your %PATH%. Since ffplay comes with ffmpeg, this should solve your problem.
You can install ffmpeg here: http://ffmpeg.org/
After installation, you can open your control panel, and then search environment. There you can adjust your %PATH% variable. Add the ffmpeg installation's binary path to the %PATH%.
And here's why from source code:
def get_encoder_name():
"""
Return enconder default application for system, either avconv or ffmpeg
"""
if which("avconv"):
return "avconv"
elif which("ffmpeg"):
return "ffmpeg"
else:
# should raise exception
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
return "ffmpeg"
def get_player_name():
"""
Return enconder default application for system, either avconv or ffmpeg
"""
if which("avplay"):
return "avplay"
elif which("ffplay"):
return "ffplay"
else:
# should raise exception
warn("Couldn't find ffplay or avplay - defaulting to ffplay, but may not work", RuntimeWarning)
return "ffplay"
def which(program):
"""
Mimics behavior of UNIX which command.
"""
# Add .exe program extension for windows support
if os.name == "nt" and not program.endswith(".exe"):
program += ".exe"
envdir_list = [os.curdir] + os.environ["PATH"].split(os.pathsep)
for envdir in envdir_list:
program_path = os.path.join(envdir, program)
if os.path.isfile(program_path) and os.access(program_path, os.X_OK):
return program_path
From this we can know that it looks up those programs from your environment variable %PATH%. And that's why installing those softwares and adding them to your %PATH% should solve the problem.
Related
I have already installed ghostscript with pip install ghostscript.
But I got the error with treepoemerror: Cannot determine path to ghostscript, is it installed?
I've changed gs to gswin64, because I've winx64:
def _get_ghostscript_binary() -> str:
binary = "gswin64"
if sys.platform.startswith("win"):
binary = EpsImagePlugin.gs_windows_binary
if not binary:
raise TreepoemError(
"Cannot determine path to ghostscript, is it installed?"
)
return binary
but I still get that error. How do I set something with Path?
Can anyone give me the steps, easily explained?
So here's it installed:
I want use moviepy so, I checking example snippets from official moviepy web site.
I installed all requirements and When I try to run moviepy on jupyter notebook, I get this error:
Code :
txt_clip = TextClip("My Holidays 2013",fontsize=70,color='white')
Error :
OSError: MoviePy Error: creation of None failed because of the following error:
[Errno 2] No such file or directory: '/usr/local/bin/convert'.
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
My os : M1 BigSur 11.2.3 - MacOS
Also I checked
ls /opt/homebrew/opt
ls /usr/local/Cellar
ls -l /usr/local/opt/
But I cannot find anything about "convert"
Btw I can user imagemagic convert from terminal like that:
magick convert
output is like that:
Version: ImageMagick 7.0.11-7 Q16 arm 2021-04-12 https://imagemagick.org
Copyright: (C) 1999-2021 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(4.5)
Delegates (built-in): bzlib freetype gslib heic jng jp2 jpeg lcms lqr ltdl lzma openexr png ps tiff webp xml zlib
Usage: convert [options ...] file [ [options ...] file ...] [options ...] file
Image Settings:
-adjoin join images into a single multi-image file
-affine matrix affine transform matrix
-alpha option activate, deactivate, reset, or set the alpha channel
-antialias remove pixel-aliasing
How can solve this? Any tip or solution?
I solved this error.
I checked my PATH
echo $PATH
After that, I checked path folders and I find 'convert' from /opt/homebrew/bin/convert
After that I copied this file to /usr/local/bin/
So,
sudo cp /opt/homebrew/bin/convert /usr/local/bin/
solved my issue.
I am making a very simple Django app (it's a test for non-Django course) and I need to analyse a mp3 file in there, so I try to turn it into wav with this:
sound = AudioSegment.from_mp3('upload/' + filename)
sound.export('upload/wavfile', format="wav")
rate, data = wav.read('upload/wavfile')
I have installed ffmpeg by pip install ffmpeg in venv terminal, since I want to my code to run not only on my machine. The ffmpeg and ffprobe folders have appeared in /venv/lib/python3.7/site-packages/ however when I run my server I get the warning:
RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg,
but may not work
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
and when I load file in web page it throws
[Errno 2] No such file or directory: 'ffprobe': 'ffprobe'
at the first line of the code above.
I would really appreciate any help with how I can use ffmpeg in my app or other ways to handle my mp3 file.
You have to add path for ffmpeg executable
import sys
sys.path.append('/path/to/ffmpeg')
or
import ffmpy
ff = ffmpy.FFmpeg(executable='C:\\ffmpeg\\bin\\ffmpeg.exe', inputs={path+'/Stage1Rap.wav': None}, outputs={path+'/FinalRap.mp3': ["-filter:a", "atempo=0.5"]})
ff.run()
In the course of maintaining a CLI utility, I want to add an update action that will grab the latest version of that package from PyPI and upgrade the existing installation.
$ cli -V
1.0.23
$ cli update
// many lines of pip spam
$ cli -V
1.0.24 // or etc
This is working perfectly on all machines that have Python installed system-wide (in C:\Python36 or similar), but machines that have Python installed as a user (in C:\users\username\AppData\Local\Programs\Python\Python36) receive this error as the old version is uninstalled:
Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'C:\\Users\\username\\AppData\\Local\\Temp\\pip-uninstall-f5a7rk2y\\cli.exe'
Consider using the `--user` option or check the permissions.
I had assumed that this is due to the fact that the cli.exe called out in the error text is currently running when pip tries to remove it, however the path here is not to %LOCALAPPDATA%\Programs\Python\Python36\Scripts where that exe lives, but instead to %TEMP%. How is it allowed to move the file there, but not remove it once it's there?
including --user in the install args as recommended by the error message does not (contrary to the indication of an earlier edit of this question) resolve the issue, but moving the cli executable elsewhere does.
I'm hoping for an answer that:
Explains the underlying issue of failing to delete the executable from the TEMP directory, and...
Provides a solution to the issue, either to bypass the permissions error, or to query to see if this package is installed as a user so the code can add --user to the args.
While the question is fairly general, a MCVE is below:
def update(piphost):
args = ['pip', 'install',
'--index-url', piphost,
'-U', 'cli']
subprocess.check_call(args)
update('https://mypypiserver:8001')
As originally surmised, the issue here was trying to delete a running executable. Windows isn't a fan of that sort of nonsense, and throws PermissionErrors when you try. Curiously though, you can definitely rename a running executable, and in fact several questions from different tags use this fact to allow an apparent change to a running executable.
This also explains why the executable appeared to be running from %LOCALAPPDATA%\Programs\Python\Python36\Scripts but failing to delete from %TEMP%. It has been renamed (moved) to the %TEMP% folder during execution (which is legal) and then pip attempts to remove that directory, also removing that file (which is illegal).
The implementation goes like so:
Rename the current executable (Path(sys.argv[0]).with_suffix('.exe'))
pip install to update the package
Add logic to your entrypoint that deletes the renamed executable if it exists.
import click # I'm using click for my CLI, but YMMV
from pathlib import Path
from sys import argv
def entrypoint():
# setup.py's console_scripts points cli.exe to here
tmp_exe_path = Path(argv[0]).with_suffix('.tmp')
try:
tmp_exe_path.unlink()
except FileNotFoundError:
pass
return cli_root
#click.group()
def cli_root():
pass
def update(pip_host):
exe_path = Path(argv[0])
tmp_exe_path = exe_path.with_suffix('.tmp')
handle_renames = False
if exe_path.with_suffix('.exe').exists():
# we're running on Windows, so we have to deal with this tomfoolery.
handle_renames = True
exe_path.rename(tmp_exe_path)
args = ['pip', 'install',
'--index-url', piphost,
'-U', 'cli']
try:
subprocess.check_call(args)
except Exception: # in real code you should probably break these out to handle stuff
if handle_renames:
tmp_exe_path.rename(exe_path) # undo the rename if we haven't updated
#cli_root.command('update')
#click.option("--host", default='https://mypypiserver:8001')
def cli_update(host):
update(host)
Great solution provided by the previous commenter: Pip install upgrade unable to remove temp files by https://stackoverflow.com/users/3058609/adam-smith
I want to add to remarks that made the code work for me (using python 3.8):
Missing parentheses for the return of the entrypoint function (however, the function I'm pointing to is not decorated with #click.group() so not sure if that's the reason)
def entrypoint():
# setup.py's console_scripts points cli.exe to here
tmp_exe_path = Path(argv[0]).with_suffix('.tmp')
try:
tmp_exe_path.unlink()
except FileNotFoundError:
pass
>>> return cli_root() <<<
Missing with_suffix('.exe') when attempting the rename in the update function. If I use the original code I get FileNotFoundError: [WinError 2] The system cannot find the file specified: '..\..\..\updater' -> '..\..\..\updater.tmp'
def update(pip_host):
exe_path = Path(argv[0])
tmp_exe_path = exe_path.with_suffix('.tmp')
handle_renames = False
if exe_path.with_suffix('.exe').exists():
# we're running on Windows, so we have to deal with this tomfoolery.
handle_renames = True
>>> exe_path.with_suffix('.exe').rename(tmp_exe_path) <<<
...
On one of my Windows 7 development machines, I am attempting to install the Python Image Library.
My machines are similar. Both run Windows 7 Professional, x64. Both use Python 2.7.3 (32bit). On one of the machine pip install PIL works fine. On the other it fails with the trace ending with this:
build\temp.win-amd64-2.7\Release\_imaging.pyd.manifest : general error c1010070:
Failed to load and parse the manifest. The system cannot find the file specified.
error: command 'mt.exe' failed with exit status 31
How can I resolve this error?
Thanks to http://bugs.python.org/issue4431, this error was fixed by modifying:
C:\<Python dir>\Lib\distutils\msvc9compiler.py
and adding:
ld_args.append('/MANIFEST')
after the MANIFESTFILE line so it looks like:
# Embedded manifests are recommended - see MSDN article titled
# "How to: Embed a Manifest Inside a C/C++ Application"
# (currently at http://msdn2.microsoft.com/en-us/library/ms235591(VS.80).aspx)
# Ask the linker to generate the manifest in the temp dir, so
# we can embed it later.
temp_manifest = os.path.join(
build_temp,
os.path.basename(output_filename) + ".manifest")
ld_args.append('/MANIFESTFILE:' + temp_manifest)
ld_args.append('/MANIFEST')
If you still get the error, then change the if arg.startswith("/MANIFESTFILE:") to if arg.startswith("/MANIFEST:") in the manifest_get_embed_info(self, target_desc, ld_args) method.
Download the compressed package from pypi, and try building and installing in your machine. This link could give you some hints. That exactly deals with your problem only but the installation varies.
If you've reached here looking for
general error c1010070:
Failed to load and parse the manifest. The system cannot find the file specified.
error: command 'mt.exe' failed with exit status 31
Here's a workaround that worked in Windows 8/x64/Python 3.3/VS 11:
# py 3.3 seems to be compiled against VS 2010 compiler, force using VS11 cl.exe for us
$env:VS100COMNTOOLS=$env:VS110COMNTOOLS
# Modify C:\Python33\lib\distutils\msvc9compiler.py
# Comment line 670: ld_args.append('/MANIFESTFILE:' + temp_manifest)
# Basically it will instruct build to not look for manifest file