Selenium Manager downloads chromedriver in code but not when compiled

264 views
Skip to first unread message

ryan rogers

unread,
Mar 3, 2025, 1:42:57 AMMar 3
to Selenium Users
I'm updating some code that I have so that I can avoid manual updating of chromedrivers. I removed them from locations I had used previously. I ran it and it pulled the correct version and the code ran. But when I try to run a complied version (command used to compile 'pyinstaller main.py --onefile') I get the following message:
Unable to obtain driver using Selenium Manager: Selenium Manager failed for: C:\Users\rrogers\AppData\Local\Temp\_MEI233482\selenium\webdriver\common\windows\selenium-manager.exe --browser chrome --output json.
The chromedriver version cannot be discovered

Am I missing a flag when compiling or does the output have a dependent file that I don't know about? The path in the error doesn't exist after "Temp\". I don't think manually adding that folder path into my PC is a proper fix for this either. 

Suggestions welcomed.

venkatesh iyengar

unread,
Mar 3, 2025, 2:20:33 AMMar 3
to seleniu...@googlegroups.com
Hi Ryan,

Can you check the modified date and time of the compiled file which could help me understand the issue ? and Also please let me know steps to successfully executing the code which you mentioned after modification. If possible share the code for the above scenario which i could replicate to provide you a solution.

Regards,
Venkatesh

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/selenium-users/517e550b-7f4d-41a9-afff-6b01f4e895f1n%40googlegroups.com.

Ryan Rogers

unread,
Mar 14, 2025, 9:50:50 AMMar 14
to seleniu...@googlegroups.com

Thanks for the response and apologies for the delay in responding.

 

The date modified is today (3:14 8:07am)

Selenium version is 4.29

The command I used to compile is – pyinstaller main.py --onefile

 

I attached the code that works fine when ran from PyCharm but not when compiled. The URL points to a locally hosted, browser based, ERP system that I’m scraping data from so I’m not sure how much you’ll be able to test.

 

 

From: seleniu...@googlegroups.com <seleniu...@googlegroups.com> On Behalf Of venkatesh iyengar
Sent: Monday, March 3, 2025 1:20 AM
To: seleniu...@googlegroups.com
Subject: Re: [selenium-users] Selenium Manager downloads chromedriver in code but not when compiled

 

⚠️ EXTERNAL E-MAIL - Think Before You Click 

--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/hEtJb0nJB5k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to selenium-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/selenium-users/CAHqOtnPNg47hTZoao5cRW4O01YY88O%2BAft-UhjRq2K0XgRvuvA%40mail.gmail.com.

air report file.txt

venkatesh iyengar

unread,
Mar 14, 2025, 11:09:12 AMMar 14
to seleniu...@googlegroups.com
Ryan,

Below are certain points for the challenges you are facing to resolve .

  When you use PyInstaller to compile Python scripts into a standalone executable, certain issues may arise that don’t appear when running the script directly in an environment like PyCharm  

PyInstaller’s environment may differ from PyCharm, especially if using a virtual environment.

Solution:

  • Create the executable from the same environment where the script runs correctly in PyCharm. Activate the environment before compiling:

source venv/bin/activate  # For Linux/Mac
venv\Scripts\activate     # For Windows
pyinstaller main.py --onefile

Please try these and let me know if it helped you resolve the issue.
Regards,
Venkatesh


Ryan Rogers

unread,
Mar 14, 2025, 11:48:43 AMMar 14
to seleniu...@googlegroups.com

Thanks for your response.

I entered the command for windows prior to compiling as you suggested. Unfortunately, I’m still getting the same error. Output below.

 

 

C:\Users\rrogers\PycharmProjects\HUsearcher\dist>main.exe

Traceback (most recent call last):

  File "selenium\webdriver\common\service.py", line 71, in start

  File "subprocess.py", line 969, in __init__

  File "subprocess.py", line 1438, in _execute_child

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 "main.py", line 23, in <module>

  File "selenium\webdriver\chrome\webdriver.py", line 69, in __init__

  File "selenium\webdriver\chromium\webdriver.py", line 89, in __init__

  File "selenium\webdriver\common\service.py", line 81, in start

selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://chromedriver.chromium.org/home

 

[17904] Failed to execute script 'main' due to unhandled exception!

venkatesh iyengar

unread,
Mar 14, 2025, 12:00:52 PMMar 14
to seleniu...@googlegroups.com
Ryan,

Is there a way we can connect  so that I can see what the issue you are having ?

Regards,
Venkatesh

Ryan Rogers

unread,
Mar 14, 2025, 12:50:24 PMMar 14
to seleniu...@googlegroups.com

I might not be able to do any meetings due to IT restrictions. But we could try.

 

Re-reading the message makes me think I may have explained things improperly in the last message.

 

I ran the 2 commands that you mentioned in the last message in pycharm. Setting the virtual environment and compiling the code into one file.

The output I sent is from when I tried to run the compiled code from windows command console after that. The window closes too fast otherwise.

venkatesh iyengar

unread,
Mar 14, 2025, 1:15:21 PMMar 14
to seleniu...@googlegroups.com
Ryan,

I understand the IT restrictions, No worries . Have you created any virtual environment in pycharm if yes then that needs to be activated before running the command . .  I have another suggestion for you . 

pyinstaller main.py --onefile --hidden-import= selenium.webdriver

Regards,
Venkatesh

Ryan Rogers

unread,
Mar 14, 2025, 2:03:26 PMMar 14
to seleniu...@googlegroups.com

I haven’t created any virtual environments in pycharm.

I attempted to use the additional flag you suggested and it unfortunately failed the same way.

 

I appreciate all of your efforts.

venkatesh iyengar

unread,
Mar 14, 2025, 2:09:08 PMMar 14
to seleniu...@googlegroups.com

Thanks Ryan,

Can you please help me with simple code to open the browser and open the Google page in it?  Provide the steps you executed for a new pycharm project and same for command line, would like to replicate it at my end so that I can help you fix the challenge.

Regards,
Venkatesh


Corey Goldberg

unread,
Mar 14, 2025, 2:26:52 PMMar 14
to seleniu...@googlegroups.com
Add `chromedriver` location to your PATH like the error message said. 

Ryan Rogers

unread,
Mar 19, 2025, 1:51:31 PMMar 19
to seleniu...@googlegroups.com

I figured I’d give this a shot.

Since I didn’t install selenium on my system manually, pycharm did that, I wasn’t sure what the path would be. I was able to find out where it was being called from by adding a couple of lines to my code.

The path I used was:

C:\Users\rrogers\.cache\selenium\chromedriver\win64\134.0.6998.88\chromedriver.exe

Added the current path to the project in pycharm, and it didn’t work. Same error message as before.

 

I’m trying to update some code so that I no longer have to manually manage chromedriver downloads for my scripts. Other users have problems with the download process, so I’m trying to automate it.

Ryan Rogers

unread,
Mar 19, 2025, 2:19:07 PMMar 19
to seleniu...@googlegroups.com

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import (ElementNotVisibleException,
                                        ElementNotSelectableException, TimeoutException)

options = Options()
options.add_argument('--allow-running-insecure-content')
options.add_argument('--ignore-certificate-errors')
driver = webdriver.Chrome(options=options)

driver.get("https://www.google.com/")

 

Steps taken.

 

file>new project

checked>create welcome script. Otherwise took defaults.

in main.py added the script above.

Clicked>Settings>Project: testingSelenium>Python Interpreter.

Clicked plus sign there to add Selenium to the project (basically pip selenium)

also checked Specify version 4.29.0, then clicked Install Package.

Package info after installing selenium is below

As before the code works fine when in the editor.

 

Compiled using the command below. In the pycharm terminal.

(cursor is in the middle as pyinstaller doesn’t like the equal sign after the hidden import flag)

 

Then in the windows cmd prompt, I get the same error message when trying to run the compiled executeable.

venkatesh iyengar

unread,
Mar 19, 2025, 9:07:01 PMMar 19
to seleniu...@googlegroups.com

Ryan,

As I see while creating a welcome script - python virtual environment is created which you could activate like venv\Scripts\activate in command line before running the script.

Regards,
Venkatesh


Ryan Rogers

unread,
Mar 26, 2025, 1:38:23 PMMar 26
to seleniu...@googlegroups.com

Is that before I compile in pycharm? I tried that and had no luck.

 

I have a total of 3 scripts that use selenium. 1 works but the other 2 don’t. I really am stumped.

venkatesh iyengar

unread,
Apr 2, 2025, 3:16:29 AMApr 2
to seleniu...@googlegroups.com
Hi Ryan ,

I have worked on the code which you gave for Google -- i am able to execute in pycharm and also on the command line based on the steps i provided for executing it  -- with a small change -- please check in the attached screenshot.


Regards,
Venkatesh
image.png

ryan rogers

unread,
Apr 9, 2025, 8:24:08 AMApr 9
to Selenium Users

Again, thanks for your continued efforts to help me solve this. It is greatly appreciated. 

It appears that you're having me check to be sure that I'm in the virtual environment before compiling. 

I had to modify what you had sent before as it didn’t seem to compile. I added “pyinstaller”Here is a screenshot of compiling in pycharm. I also have attached a copy of the output generated when I compiled.

Here are the results from when I run the compiled code from the windows command prompt

Still no idea why I have one piece of compiled code that uses the Selenium Manager function properly and I have this path error for everything else. 
TestingSeleniumCompileInfo.txt

ryan rogers

unread,
Apr 9, 2025, 8:27:01 AMApr 9
to Selenium Users
adding screenshots as they didn't post properlyselenium1.pngselenium2.png

Corey Goldberg

unread,
Apr 9, 2025, 12:21:46 PMApr 9
to seleniu...@googlegroups.com

As the error message states... it can't find chromedriver and you need to add it to your PATH.


Ryan Rogers

unread,
Apr 10, 2025, 2:27:29 PMApr 10
to seleniu...@googlegroups.com

I could very easily just add the latest chromedriver to the same folder as the executable. That works just as well as updating the system path, but then I’m stuck with manually updating the version of chromedriver on every computer every time chrome updates automatically, which is a pain.

 

Selenium added a feature a year or so ago that does the driver management without needing to manually update the chromedriver to match the version of chrome. I have one program that Selenium Manager opens chrome perfectly, both pycharm and compiled file. Yet, any other code using chromedriver only opens chrome in pycharm and not when compiled.

 

Adding the path tells Seleium Manager to not run and I’ll be manually updating the chromedriver file  every chrome update again. That is why I haven’t done what the error message obviously states I should do.

 

From Selenium’s documentation:

“Driver management through Selenium Manager is opt-in for the Selenium bindings. Thus, users can continue managing their drivers manually (putting the driver in the PATH or using system properties) or rely on a third-party driver manager to do it automatically. Selenium Manager only operates as a fallback: if no driver is provided, Selenium Manager will come to the rescue.”

https://www.selenium.dev/documentation/selenium_manager/

 

I suppose I could try one of the third party driver managers instead.

 

From: seleniu...@googlegroups.com <seleniu...@googlegroups.com> On Behalf Of Corey Goldberg
Sent: Wednesday, April 9, 2025 11:21 AM
To: seleniu...@googlegroups.com
Subject: Re: [selenium-users] Selenium Manager downloads chromedriver in code but not when compiled

 

⚠️ EXTERNAL E-MAIL - Think Before You Click 

As the error message states... it can't find chromedriver and you need to add it to your PATH.

 

On Wed, Apr 9, 2025, 8:27 AM ryan rogers <rro...@indsvccorp.com> wrote:

adding screenshots as they didn't post properly

On Wednesday, April 9, 2025 at 7:24:08AM UTC-5 ryan rogers wrote:

Again, thanks for your continued efforts to help me solve this. It is greatly appreciated. 

It appears that you're having me check to be sure that I'm in the virtual environment before compiling. 

I had to modify what you had sent before as it didn’t seem to compile. I added “pyinstaller”Here is a screenshot of compiling in pycharm. I also have attached a copy of the output generated when I compiled.

Here are the results from when I run the compiled code from the windows command prompt

Still no idea why I have one piece of compiled code that uses the Selenium Manager function properly and I have this path error for everything else. 

On Wednesday, April 2, 2025 at 2:16:29AM UTC-5 venkates...@gmail.com wrote:

Hi Ryan ,

 

I have worked on the code which you gave for Google -- i am able to execute in pycharm and also on the command line based on the steps i provided for executing it  -- with a small change -- please check in the attached screenshot.

 

 

Regards,

Venkatesh

Reply all
Reply to author
Forward
0 new messages