breuerfelix / chromedriver-py

chromedriver self updated binaries for all platforms
https://pypi.org/project/chromedriver-py/
Apache License 2.0
52 stars 15 forks source link

Issue with using pyInstaller / auto-py-2-exe and chromedriver_py #16

Closed VlexWest closed 9 months ago

VlexWest commented 2 years ago

Hello, it is my first time using GitHub Issue, so I hope I don't mess it up.

I'm trying to convert a python file to an *.exe with "chromedriver_py" in it.

In PyCharm my program is working perfectly, no errors / exceptions or anything, but when I'm converting it to exe using PyInstaller or autopy2exe, no matter if it's onefile, or onedirectory (bundle) it throws me an error:

Traceback (most recent call last):
  File "testscript.py", line 25, in <module>
    from chromedriver_py import binary_path
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
  File "chromedriver_py\__init__.py", line 36, in <module>
  File "chromedriver_py\__init__.py", line 31, in _get_filename
Exception: Couldn't find a binary for your system: windows / amd64. Please create an Issue on github.com/breuerfelix/chromedriver-py and include this Message.

--

I'm importing it like this (with selenium, but you can ignore that, I guess):

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from selenium.common.exceptions import WebDriverException
from selenium.webdriver.chrome.service import Service
from subprocess import CREATE_NO_WINDOW
from chromedriver_py import binary_path  # chromedriver_py

And using it in code:

# Just a small test function
def test_func():
    chrome_options = Options()
    chrome_options.add_argument("--start-maximized")
    service = Service(binary_path)  # Getting the binary path of Chromedriver
    service.creationflags = CREATE_NO_WINDOW  # No cmd-prompt when selenium's working

    driver = webdriver.Chrome(options=chrome_options, service=service)

I've tried also to use --hidden-import with chromedriver_py as a pyInstaller option, sadly it also not worked.

Some details:

Python 3.10.0
PyInstaller 4.8
chromedriver_py >97, <98
selenium 4.1.0

I would be very, very, very thankful if you could help me out with this.

breuerfelix commented 9 months ago

See my answer in #33 . You won't ever be able to package the chromedriver bin together into one exe file :)