Skip to content

OSError: [Errno 86] Bad CPU type in executable - downloading uc_driver on MacOS #2558

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Dylgod opened this issue Mar 1, 2024 · 6 comments
Closed
Labels
UC Mode / CDP Mode Undetected Chromedriver Mode / CDP Mode workaround exists You can reach your destination if you do this...

Comments

@Dylgod
Copy link

Dylgod commented Mar 1, 2024

Device: Mac Mini
MacOS: Sonoma 14.3.1 (23D60)
Chrome: Version 122.0.6261.94 (Official Build) (arm64)

When running this code:

from seleniumbase import Driver
from selenium.webdriver.common.by import By

web = Driver(browser='chrome', uc=True)

web.get("https://www.youtube.com")
web.sleep(5)
print(web.find_element(By.XPATH, '/html/body').text)
web.quit()

I get back

Warning: uc_driver update needed. Getting it now:

*** chromedriver to download = 122.0.6261.94 (Latest Stable) 

Downloading chromedriver-mac-x64.zip from:
https://storage.googleapis.com/chrome-for-testing-public/122.0.6261.94/mac-x64/chromedriver-mac-x64.zip ...
Download Complete!

Extracting ['chromedriver'] from chromedriver-mac-x64.zip ...
Unzip Complete!

The file [uc_driver] was saved to:
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/seleniumbase/drivers/uc_driver

Making [uc_driver 122.0.6261.94] executable ...
[uc_driver 122.0.6261.94] is now ready for use!

Traceback (most recent call last):
  File "/Users/shy/PycharmProjects/pythonProject/shy_drivers/mac_shytest.py", line 4, in <module>
    web = Driver(browser='chrome', uc=True)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/seleniumbase/plugins/driver_manager.py", line 488, in Driver
    driver = browser_launcher.get_driver(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/seleniumbase/core/browser_launcher.py", line 1612, in get_driver
    return get_local_driver(
           ^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/seleniumbase/core/browser_launcher.py", line 3510, in get_local_driver
    driver = undetected.Chrome(
             ^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/seleniumbase/undetected/__init__.py", line 312, in __init__
    super().__init__(options=options, service=service_)
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
    super().__init__(
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/selenium/webdriver/chromium/webdriver.py", line 50, in __init__
    self.service.start()
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/selenium/webdriver/common/service.py", line 98, in start
    self._start_process(self._path)
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/selenium/webdriver/common/service.py", line 208, in _start_process
    self.process = subprocess.Popen(
                   ^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 1953, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 86] Bad CPU type in executable: '/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/seleniumbase/drivers/uc_driver'

I am new to to Mac so it is possible i have done something wrong.

@mdmintz mdmintz added workaround exists You can reach your destination if you do this... UC Mode / CDP Mode Undetected Chromedriver Mode / CDP Mode labels Mar 1, 2024
@mdmintz
Copy link
Member

mdmintz commented Mar 1, 2024

Related to ultrafunkamsterdam/undetected-chromedriver#1020 (comment)

You need Rosetta 2 on your Mac:

softwareupdate --install-rosetta

@mdmintz mdmintz closed this as completed Mar 1, 2024
@Dylgod
Copy link
Author

Dylgod commented Mar 2, 2024

Thank you! Also wondering if i were to create an .app and distribute it would i need to bundle Rosetta 2 with it?

@mdmintz
Copy link
Member

mdmintz commented Mar 2, 2024

Do you mean with Pyinstaller? Not sure… it probably depends on the system.

@Dylgod
Copy link
Author

Dylgod commented Mar 2, 2024

Yeah I currently use Pyinstaller to package a windows app and it works great for windows. I hope to do the same on Mac.

Is there an Apple Silicon build of UC? Or does the auto-fetch for uc_driver only have a build for Intel?

If there's only an Intel build then is there a way to get an Apple Silicon build?

(Apologies if my understanding of the situation isn't quite right, this is day 1 of entering the Mac universe for me)

@mdmintz
Copy link
Member

mdmintz commented Mar 2, 2024

The chromedriver-to-uc_driver conversion script on a Mac only works with the Intel chromedriver. But that's not an issue if Rosetta 2 is installed.

@mdmintz
Copy link
Member

mdmintz commented Jan 30, 2025

Fix "Bad CPU type" with Rosetta 2: https://apple.stackexchange.com/a/408379/607628

Image

softwareupdate --install-rosetta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
UC Mode / CDP Mode Undetected Chromedriver Mode / CDP Mode workaround exists You can reach your destination if you do this...
Projects
None yet
Development

No branches or pull requests

2 participants