Skip to content

Commit 51ec1c7

Browse files
committed
Improve output when Rosetta 2 is missing/needed on macOS
1 parent b64cbd8 commit 51ec1c7

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

seleniumbase/undetected/__init__.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"CDP",
2626
"find_chrome_executable",
2727
)
28+
IS_MAC = "darwin" in sys.platform
2829
IS_POSIX = sys.platform.startswith(("darwin", "cygwin", "linux"))
2930
logger = logging.getLogger("uc")
3031
logger.setLevel(logging.getLogger().getEffectiveLevel())
@@ -311,7 +312,21 @@ def __init__(
311312
setattr(service_, "creationflags", creationflags)
312313
if hasattr(service_, "creation_flags"):
313314
setattr(service_, "creation_flags", creationflags)
314-
super().__init__(options=options, service=service_)
315+
try:
316+
super().__init__(options=options, service=service_)
317+
except OSError as e:
318+
if IS_MAC and "Bad CPU type in executable" in str(e):
319+
print(str(e))
320+
message = (
321+
"Missing a macOS dependency:\n"
322+
"Your Mac needs Rosetta 2 to use UC Mode!\n"
323+
'Run: "softwareupdate --install-rosetta"\n'
324+
"Info: "
325+
"https://apple.stackexchange.com/a/408379/607628"
326+
)
327+
raise Exception(message)
328+
else:
329+
raise
315330
self.reactor = None
316331
if enable_cdp_events:
317332
if logging.getLogger().getEffectiveLevel() == logging.DEBUG:

0 commit comments

Comments
 (0)