FFMPEG - [WinError 2] The system cannot find the file specified - python-3.x

I'm having an issue using the FFmpeg package.
Here's my code :
import ffmpeg_streaming
from ffmpeg_streaming import Formats, Bitrate, Representation, Size
_360p = Representation(Size(640, 360), Bitrate(276 * 1024, 128 * 1024))
_480p = Representation(Size(854, 480), Bitrate(750 * 1024, 192 * 1024))
_720p = Representation(Size(1280, 720), Bitrate(2048 * 1024, 320 * 1024))
hls = video.hls(Formats.h264())
hls.representations(_360p, _480p, _720p)
hls.output('C:/Users/juled/Videos/testStreaming')
Quite simple as you can see, found it on the web.
And here's the error message I have:
Traceback (most recent call last):
File "C:\Users\juled\OneDrive\Bureau\PACT\streamingMultimedia\streaming.py", line 50, in <module>
hls.output('C:/Users/juled/Videos/testStreaming')
File "C:\Users\juled\OneDrive\Bureau\Informatique\WPy64-3760\python-3.7.6.amd64\lib\site-packages\ffmpeg_streaming\_media.py", line 93, in output
self.run(ffmpeg_bin, monitor, **options)
File "C:\Users\juled\OneDrive\Bureau\Informatique\WPy64-3760\python-3.7.6.amd64\lib\site-packages\ffmpeg_streaming\_media.py", line 121, in run
asyncio.run(self.async_run(ffmpeg_bin, monitor, **options))
File "C:\Users\juled\OneDrive\Bureau\Informatique\WPy64-3760\python-3.7.6.amd64\lib\asyncio\runners.py", line 43, in run
return loop.run_until_complete(main)
File "C:\Users\juled\OneDrive\Bureau\Informatique\WPy64-3760\python-3.7.6.amd64\lib\asyncio\base_events.py", line 583, in run_until_complete
return future.result()
File "C:\Users\juled\OneDrive\Bureau\Informatique\WPy64-3760\python-3.7.6.amd64\lib\site-packages\ffmpeg_streaming\_media.py", line 112, in async_run
self._run(ffmpeg_bin, monitor, **options)
File "C:\Users\juled\OneDrive\Bureau\Informatique\WPy64-3760\python-3.7.6.amd64\lib\site-packages\ffmpeg_streaming\_media.py", line 105, in _run
with Process(self, command_builder(ffmpeg_bin, self), monitor, **options) as process:
File "C:\Users\juled\OneDrive\Bureau\Informatique\WPy64-3760\python-3.7.6.amd64\lib\site-packages\ffmpeg_streaming\_process.py", line 58, in __init__
self.process = _p_open(commands, **options)
File "C:\Users\juled\OneDrive\Bureau\Informatique\WPy64-3760\python-3.7.6.amd64\lib\site-packages\ffmpeg_streaming\_process.py", line 29, in _p_open
return subprocess.Popen(shlex.split(commands), **options)
File "C:\Users\juled\OneDrive\Bureau\Informatique\WPy64-3760\python-3.7.6.amd64\lib\subprocess.py", line 800, in __init__
restore_signals, start_new_session)
File "C:\Users\juled\OneDrive\Bureau\Informatique\WPy64-3760\python-3.7.6.amd64\lib\subprocess.py", line 1207, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
I've been checking every file quoted in the error message, but only one of them is "my" code, the others are FFmpeg and Python libraries codes.
I'm using IDLEX for Python 3.7.6 on Windows by the way.
I've tried to change some of the FFmpeg library code, especially where subprocess.Popen appears, by putting a shell=True in the parameters. New Error Message, different this time.
I've added FFmpeg to the PATH, no change.
I've reinstalled FFmpeg to be sure, but no change. I'm using this version: python-ffmpeg-video-streaming-0.1.14.
Do any of you have a solution I could try ?
Oh and a friend has the same issue on MAC.

This is a PATH environment variable issue. Based on this link, you could try:
import os
path = 'the path you want'
os.environ['PATH'] += ';'+path
to add the path to ffmpeg.exe to your system path (and also to check if your python instance is really looking at the correct path), and you can also change pythonpath,
import sys
sys.path.insert(0,'path/to/ffmpeg')
Note how these two are totally different. However, I find that the easiest way with programs like ffmpeg, which are self-contained executables, that you can just copy them to the working directory of your script and then run it, which is what solved your problem.

Related

Unable to use Graphviz library in Python

Here is the code I try to execute:
from graphviz import Graph
# Instantiate a new Graph object
dot = Graph('Data Science Process', format='png')
# Add nodes
dot.node('A', 'Get Data')
dot.node('B', 'Clean, Prepare, & Manipulate Data')
dot.node('C', 'Train Model')
dot.node('D', 'Test Data')
dot.node('E', 'Improve')
# Connect these nodes
dot.edges(['AB', 'BC', 'CD', 'DE'])
# Save chart
#dot.render('data_science_flowchart', view=True)
The render function won't work, and I have not idea what is wrong. If commented out, the code works, but of course produces nothing. My goal is to make a visualization of the graph (PNG image, or PDF file). Just trying to plot a rudimentary flowchart in Python, I am open to using other libraries than graphviz: I am new to this, and tried graphviz after reading recommendations, tested a dozen scripts posted online, but none of them work, always resulting in the same error.
Here is the error:
$ py graph2.py
py graph2.py
Traceback (most recent call last):
File "C:\Users\vince\AppData\Local\Programs\Python\Python310\lib\site-packages\graphviz\backend\execute.py", line 81, in run_check
proc = subprocess.run(cmd, **kwargs)
File "C:\Users\vince\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 501, in run
with Popen(*popenargs, **kwargs) as process:
File "C:\Users\vince\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 966, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\vince\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1435, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\vince\graph2.py", line 17, in <module>
dot.render('data_science_flowchart', view=True)
File "C:\Users\vince\AppData\Local\Programs\Python\Python310\lib\site-packages\graphviz\_tools.py", line 171, in wrapper
return func(*args, **kwargs)
File "C:\Users\vince\AppData\Local\Programs\Python\Python310\lib\site-packages\graphviz\rendering.py", line 122, in render
rendered = self._render(*args, **kwargs)
File "C:\Users\vince\AppData\Local\Programs\Python\Python310\lib\site-packages\graphviz\_tools.py", line 171, in wrapper
return func(*args, **kwargs)
File "C:\Users\vince\AppData\Local\Programs\Python\Python310\lib\site-packages\graphviz\backend\rendering.py", line 324, in render
execute.run_check(cmd,
File "C:\Users\vince\AppData\Local\Programs\Python\Python310\lib\site-packages\graphviz\backend\execute.py", line 84, in run_check
raise ExecutableNotFound(cmd) from e
graphviz.backend.execute.ExecutableNotFound: failed to execute WindowsPath('dot'), make sure the Graphviz executables are on your systems' PATH

Getting error about ImageMagick With Python/MoviePy when I try add text clip

I am using python 3.8.5 as well as the latest version of imagemagick and moviepy
error (vs code):
Traceback (most recent call last):
File "C:\Users\edgib102\AppData\Local\Programs\Python\Python38-32\lib\site-packages\moviepy\video\VideoClip.py", line 1137, in __init__
subprocess_call(cmd, logger=None)
File "C:\Users\edgib102\AppData\Local\Programs\Python\Python38-32\lib\site-packages\moviepy\tools.py", line 46, in subprocess_call
proc = sp.Popen(cmd, **popen_params)
File "C:\Users\edgib102\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\edgib102\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 1307, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, 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/edgib102/source/repos/Reddit-tts-video/Python/GetComments.py", line 40, in <module>
TextClip = TextClip('TextTxt', fontsize=100, color = 'white')
File "C:\Users\edgib102\AppData\Local\Programs\Python\Python38-32\lib\site-packages\moviepy\video\VideoClip.py", line 1146, 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
Code:
TextClip = TextClip('TextTxt', fontsize=100, color = 'white')
TextClip = TextClip.set_position('center').set_duration(10)
Any help at all would be much appreciated, also full code here
Solved. Just need to set the magick.exe file path as the variable inside default_config.py. You can find it in the moviepy folder.
Add the magick.exe path to IMAGEMAGICK_BINARY in config_defaults.py.
By default it should look like this
IMAGEMAGICK_BINARY = os.getenv('IMAGEMAGICK_BINARY', 'auto-detect')
After
IMAGEMAGICK_BINARY = os.getenv('IMAGEMAGICK_BINARY', 'C:\\Program Files\\ImageMagick_VERSION\\magick.exe')

How to fix FileNotFoundError: [WinError 2] The system cannot find the file specified with AudioSegment.from_mp3()

I've been trying to find the position of spaces of audio silence in the audio of a video, but I can't get past just importing an audio file with pydub in python 3
I've already tried changing the directory that pydub is checking for ffmpeg to one within the project, and the file is in the directory I'm running the script from but it still seems to return the same error.
from moviepy import editor
from pydub import silence, AudioSegment
from pathlib import Path
import os
AudioSegment.converter = r"C:\\Users\\ratee\\PycharmProjects\\untitled\\ffmpeg\\bin\\ffmpeg.exe"
vid = editor.VideoFileClip("video.mp4")
print(AudioSegment.ffmpeg)
my_file = Path("audio.mp3")
if not my_file.is_file():
vid.audio.write_audiofile("audio.mp3")
audio = AudioSegment.from_mp3("audio.mp3")
print(audio)
I expect it to store the mp3 audio segment into the variable audi but it returns:
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.1\helpers\pydev\pydevd.py", line 1741, in <module>
main()
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.1\helpers\pydev\pydevd.py", line 1735, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.1\helpers\pydev\pydevd.py", line 1135, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.1\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Users/ratee/PycharmProjects/untitled/fuc.py", line 12, in <module>
song = AudioSegment.from_mp3("audio.mp3")
File "C:\Users\ratee\PycharmProjects\untitled\venv\lib\site-packages\pydub\audio_segment.py", line 716, in from_mp3
return cls.from_file(file, 'mp3', parameters=parameters)
File "C:\Users\ratee\PycharmProjects\untitled\venv\lib\site-packages\pydub\audio_segment.py", line 665, in from_file
info = mediainfo_json(orig_file)
File "C:\Users\ratee\PycharmProjects\untitled\venv\lib\site-packages\pydub\utils.py", line 263, in mediainfo_json
res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
File "C:\Users\ratee\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 756, in __init__
restore_signals, start_new_session)
File "C:\Users\ratee\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 1155, in _execute_child
startupinfo)
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.1\helpers\pydev\_pydev_bundle\pydev_monkey.py", line 452, in new_CreateProcess
return getattr(_subprocess, original_name)(app_name, patch_arg_str_win(cmd_line), *args)
FileNotFoundError: [WinError 2] The system cannot find the file specified
print(AudioSegment.ffmpeg)
returns as expected
C:\Users\ratee\PycharmProjects\untitled\ffmpeg\bin\ffmpeg.exe
print(my_file) returns
returns as expected
audio.mp3
and the code stops running at the point where I try to import audio
audio = AudioSegment.from_mp3("audio.mp3")
First part of the answer tries to reproduce OPs error for comparison reason. Thereafter finding a solution via update 1 and finally update 2. The folder-names x, y are used to shorten pathlengths.
Reproducing it threw me the following errors:
Error One:
c:\x\lib\site-packages\pydub\utils.py:165: 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)
c:\x\lib\site-packages\pydub\utils.py:193: RuntimeWarning: Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work
warn("Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work", RuntimeWarning)
Error Two:
Traceback (most recent call last):
File "C:\y\lol.py", line 16, in <module>
audi = AudioSegment.from_mp3("audio.mp3")
File "c:\x\lib\site-packages\pydub\audio_segment.py", line 716, in from_mp3
return cls.from_file(file, 'mp3', parameters=parameters)
File "c:\x\lib\site-packages\pydub\audio_segment.py", line 665, in from_file
info = mediainfo_json(orig_file)
File "c:\x\lib\site-packages\pydub\utils.py", line 263, in mediainfo_json
res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
File "c:\x\lib\subprocess.py", line 676, in __init__
restore_signals, start_new_session)
File "c:\x\lib\subprocess.py", line 957, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
The following code is to check if ffmpeg and ffprobe can be found:
AudioSegment.ffmpeg = os.getcwd()+"\\ffmpeg\\bin\\ffmpeg.exe"
print (AudioSegment.ffmpeg)
1) C:\y\ffmpeg\bin\ffmpeg.exe
And:
my_file = Path("audio.mp3")
print (my_file)
gives:
2) audio.mp3
Proposed solution:
Include the following specific codeline to specify where the ffmpeg is located:
pydub.AudioSegment.converter = r"C:\\path\\to\\ffmpeg.exe" where path\to\ is the actual path
And you should be fine.
Update 1:
You're raised error is due to the use of the filename at "my_file" and not "filepath" as required by AudioSegment.from_mp3(my_file). By providing the filepath this fixes the raised [WinError2] issue.
When you run below script the AttributeError: 'WindowsPath' object has no attribute 'read' error occurs. The error is related to pathlib and should have be been fixed in pydub 0.22 version as discussed here at github. I've raised the issue at Github.
The file.read() issue raised is python version related (2.7 vs. 3.5) because its nolonger in its build-in library. Therefore the .read() triggers the AttributeError: 'WindowsPath' object has no attribute 'read' error.
from pydub import silence, AudioSegment
from pathlib import Path
import os, sys
print (sys.version)
#AudioSegment.ffmpeg = os.getcwd()+"\\ffmpeg\\bin\\ffmpeg.exe"
AudioSegment.converter = r"C:\\x\\build\\win\\64\\ffmpeg.exe"
AudioSegment.ffprobe = r"C:\\x\\build\\win\\64\\ffprobe.exe"
#print (AudioSegment.converter)
#print (AudioSegment.ffprobe)
my_file = Path("C:\\y\\audio.mp3")
print ('ID1 : %s' % my_file)
audio = AudioSegment.from_mp3(my_file) # solves ***[WinError2]*** issue.
Update 2:
As update 1 solves a platform version issue update 2 solves the issue in error one and two at the same time if solution 1 in update 1 doesn't solve it yet.
Include in your script directly after the import statements the following lines:
mypaths = os.getenv('PATH').split(';') # replace 'PATH' by 'your search path' if needed.
for i in mypaths:
if i.find('python'):
print(i)
The printout shows you whether you have included the location of FFmpeg files or not. If not you need to reboot windows due to the fact the windows environment paths are not updated while you are currently in a python environment/editor.
In my case after reboot c:\y\FFmpeg\ showed up under 'PATH' and all warnings in error one and two were gone.
I met with the same problem.
pydub.AudioSegment.converter = os.getcwd()+ "\\ffmpeg.exe"
pydub.AudioSegment.ffprobe = os.getcwd()+ "\\ffprobe.exe"
sound = pydub.AudioSegment.from_mp3(os.getcwd()+"\\sample.mp3")
And everything is OK
I encountered the same problem but apparently even after adding ffmpeg path it still gives the same error. I tried this in Linux without extra commands like AudioSegment.converter = 'path\to\ffmpeg' it works fine, the problem is with Windows IDEs (pycharm, spyder, etc). Try running script directly from your prompt(anaconda, cmd, etc.) in windows. It should work.
Refrence: https://github.com/jiaaro/pydub/issues/319

psutil.AccessDenied Error while trying to load StanfordCoreNLP

I'm trying to load the package StanfordCoreNLP to get the correct parsing for the movie reviews presented in their page (https://nlp.stanford.edu/sentiment/treebank.html): (I'm using MAC)
nlp = StanfordCoreNLP("/Users//NLP_models/stanford-corenlp-full-2018-01-31")
But get the error:
Traceback (most recent call last):
File "/Users/anaconda3/lib/python3.6/site-packages/psutil/_psosx.py", line 295, in wrapper
return fun(self, *args, **kwargs)
File "/Users/anaconda3/lib/python3.6/site-packages/psutil/_psosx.py", line 480, in connections
rawlist = cext.proc_connections(self.pid, families, types)
PermissionError: [Errno 1] Operation not permitted
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 2411, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 1802, in run
launch(file, globals, locals) # execute the script
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
...
...
...
File "/Users/anaconda3/lib/python3.6/site-packages/stanfordcorenlp/corenlp.py", line 79, in __init__
if port_candidate not in [conn.laddr[1] for conn in psutil.net_connections()]:
File "/Users/anaconda3/lib/python3.6/site-packages/psutil/__init__.py", line 2191, in net_connections
return _psplatform.net_connections(kind)
File "/Users/anaconda3/lib/python3.6/site-packages/psutil/_psosx.py", line 229, in net_connections
cons = Process(pid).connections(kind)
File "/Users/anaconda3/lib/python3.6/site-packages/psutil/_psosx.py", line 300, in wrapper
raise AccessDenied(self.pid, self._name)
psutil.AccessDenied: psutil.AccessDenied (pid=5488)
I tried
conda update conda
conda update anaconda-navigator
conda update navigator-updater
But it didn't help.
Any ideas??
Thanks!!
I have the same problem, and I got it work by running the code using sudo like below:
sudo /Users/edamame/workspace/git/chinese_nlp/venv/bin/python3 chinese_segmenter1.py
Hope this works for you as well.
Same problem here.
A lot of discussion of this points to https://github.com/ContinuumIO/anaconda-issues/issues/1984, which suggests updating to the latest Navigator, and running as root (via sudo).
I've tried both and see no change at all (you may be more fortunate).
https://github.com/Lynten/stanford-corenlp/issues/26 references a tweaked version of corenlp.py that claims to avoid the problem, though I haven't gotten it to work either.
This problem seems to be specific to Mac OS X which would not allow Python to check the current port.
Comment this portion of code of corenlp.py file:
if self.port is None:
for port_candidate in range(9000, 65535):
if port_candidate not in [conn.laddr[1] for conn in psutil.net_connections()]:
self.port = port_candidate
break
if self.port in [conn.laddr[1] for conn in psutil.net_connections()]:
raise IOError('Port ' + str(self.port) + ' is already in use.')
Replace by this line:
self.port = 9999
Source: https://github.com/Lynten/stanford-corenlp/issues/26#issuecomment-445507811
Another solution is to run StanfordCoreNLP with a sudo command line.

py2app TypeError: dyld_find() got an unexpected keyword argument 'loader'

I'm having difficulty building my app using py2app. I can build it in alias mode without issue using this command:
python3.4 setup.py py2app -A
However when I try and build it using:
python3.4 setup.py py2app
I get the error message as per title of this post. From the research I've done I believe it's an issue with Pillow; however I need Pillow for this app. (Unless there's another module I can use to import images??). I've also tried cx_freeze without success.
Any help or direction much appreciated.
Full traceback as follows:
Traceback (most recent call last):
File "setup.py", line 19, in <module>
setup_requires=['py2app'],
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
distutils/core.py", line 148, in setup dist.run_commands()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
distutils/dist.py", line 955, in run_commands self.run_command(cmd)
File"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
distutils/dist.py", line 974, in run_command cmd_obj.run()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site- packages/py2app/build_app.py", line 659, in run self._run()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site- packages/py2app/build_app.py", line 865, in _run self.run_normal()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site- packages/py2app/build_app.py", line 959, in
run_normal self.create_binaries(py_files, pkgdirs, extensions,loader_files)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site- packages/py2app/build_app.py", line 1214, in create_binaries
platfiles = mm.run()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site-packages/macholib/MachOStandalone.py", line 105, in run
mm.run_file(fn)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site-packages/macholib/MachOGraph.py", line 84, in run_file
self.scan_node(m)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site-packages/macholib/MachOGraph.py", line 110, in scan_node
m = self.load_file(filename, caller=node)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site-packages/macholib/MachOGraph.py", line 93, in load_file
newname = self.locate(name, loader=caller)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site-packages/macholib/MachOStandalone.py", line 23, in locate
newname = super(FilteredMachOGraph, self).locate(filename, loader)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site-packages/macholib/MachOGraph.py", line 49, in locate
loader=loader.filename)
TypeError: dyld_find() got an unexpected keyword argument 'loader'
This is a temporary solution, and it may break other things. I would recommend doing this is a virtual environment so you don't mess up your regular packages. This worked for me (virtenv is the name of my virtual environment)
Open the file /virtenv/lib/python3.4/site-packages/macholib/dyld.py and replace each instance of loader_path with loader. Now save and try again.
You can monkey-patch macholib rather than modifying it in site-packages. Place the following file to the directory containing setup_py2app.py and add import macholib_patch to the top.
macholib_patch.py:
"""
Monkey-patch macholib to fix "dyld_find() got an unexpected keyword argument 'loader'".
Add 'import macholib_patch' to the top of set_py2app.py
"""
import macholib
#print("~"*60 + "macholib verion: "+macholib.__version__)
if macholib.__version__ <= "1.7":
print("Applying macholib patch...")
import macholib.dyld
import macholib.MachOGraph
dyld_find_1_7 = macholib.dyld.dyld_find
def dyld_find(name, loader=None, **kwargs):
#print("~"*60 + "calling alternate dyld_find")
if loader is not None:
kwargs['loader_path'] = loader
return dyld_find_1_7(name, **kwargs)
macholib.MachOGraph.dyld_find = dyld_find

Resources