--
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.
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.
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:
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!
To view this discussion visit https://groups.google.com/d/msgid/selenium-users/CAHqOtnO0FP7iXQXMTK1_GhBqqx3QF%2B6r_vzuNdMt%3DsUzO-D9Rg%40mail.gmail.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.
To view this discussion visit https://groups.google.com/d/msgid/selenium-users/CAHqOtnPXO%2BGzjRSOW81dqZQ_7tQUNT4QyRzAp5YgpVcYzRDD8w%40mail.gmail.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.
To view this discussion visit https://groups.google.com/d/msgid/selenium-users/CAHqOtnNXAw9wnvvBYayZ0zeSSetVoopgccrjJ55oAtFtkXWLbw%40mail.gmail.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
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.
To view this discussion visit https://groups.google.com/d/msgid/selenium-users/CACxX9evPW8P9cnWD6y1VWXZ45g291gqOPcNMezR6LPWg%3DGrP9w%40mail.gmail.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.
To view this discussion visit https://groups.google.com/d/msgid/selenium-users/CAHqOtnPVp6C1aFL6nkVoRs%2Bq0-57ZR60f659K9ZwXZwqp6N8WQ%40mail.gmail.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
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.
To view this discussion visit https://groups.google.com/d/msgid/selenium-users/CAHqOtnNiBWdH1AJQqdX-3oj%2B2Y%2BvTSxGy%2BJYNQCqcbR5Ck0VnQ%40mail.gmail.com.
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
As the error message states... it can't find chromedriver and you need to add it to your PATH.
To view this discussion visit https://groups.google.com/d/msgid/selenium-users/61e30ad5-9d3d-4beb-a884-879f9e377729n%40googlegroups.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:08 AM 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:29 AM 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
To view this discussion visit https://groups.google.com/d/msgid/selenium-users/CACxX9euXRqqus%2ByfmvdSC-jEpYfaiSe6AttdxSTKyjiE7UkS0A%40mail.gmail.com.