diff --git a/lbry/file_analysis.py b/lbry/file_analysis.py index 3b9a25878..550ffc6a1 100644 --- a/lbry/file_analysis.py +++ b/lbry/file_analysis.py @@ -7,6 +7,8 @@ import re import shlex import shutil import platform + +import lbry.utils from lbry.conf import TranscodeConfig log = logging.getLogger(__name__) @@ -28,7 +30,9 @@ class VideoFileAnalyzer: self._which = None self._checked_ffmpeg = False self._env_copy = dict(os.environ) - self._replace_or_pop_env('LD_LIBRARY_PATH') + if lbry.utils.is_running_from_bundle(): + # handle the situation where PyInstaller overrides our runtime environment: + self._replace_or_pop_env('LD_LIBRARY_PATH') async def _execute(self, command, arguments): if DISABLED: diff --git a/lbry/utils.py b/lbry/utils.py index 65d33b3e2..c24d8a971 100644 --- a/lbry/utils.py +++ b/lbry/utils.py @@ -4,6 +4,7 @@ import datetime import random import socket import string +import sys import json import typing import asyncio @@ -276,3 +277,8 @@ async def get_external_ip() -> typing.Optional[str]: # used if upnp is disabled return response['data']['ip'] except Exception: return + + +def is_running_from_bundle(): + # see https://pyinstaller.readthedocs.io/en/stable/runtime-information.html + return getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS')