Skip to content
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

Whitespace in Windows username causing non-critical error - Can I resolve this somehow? #1996

Closed
ScriptKiddie-1234 opened this issue Aug 11, 2023 · 9 comments · Fixed by #1999
Assignees
Labels
bug Uh oh... Something needs to be fixed question Someone is looking for answers UC Mode Undetected Chromedriver Mode (--uc)

Comments

@ScriptKiddie-1234
Copy link

Hello, I'm quite new to coding so please bear with me...

I'm using seleniumbase in python with VSCode in the following script:

from seleniumbase import SB

with SB(browser='chrome',uc=True) as sb:
    print(type(sb))

however, when the script runs, I get 3 error reports of the nature "'C:\Users<username segment before whitespace>' is not recognized as an internal or external command, operable program or batch file."

I believe I have added everything to the windows environment variables and the fact that the path (and username) is incomplete makes me think the whitespace in my username doesn't play well with something in the code.

That said, the 3 error reports are the only issue - the script does return "<class 'seleniumbase.fixtures.base_case.BaseCase'>" afterwards. Also trials with actual urls and using other methods work swimmingly. So this maybe a non-issue, but if possible, I would like to resolve it somehow.

@mdmintz , your repo is fantastic!

@mdmintz mdmintz added the question Someone is looking for answers label Aug 11, 2023
@mdmintz
Copy link
Member

mdmintz commented Aug 11, 2023

Hello! Thank you. Is this happening on your print() line? Seems odd that a type can't be printed, but maybe converting to a string first would help?

print(str(type(sb)))

I can't reproduce your issue. If it's happening on a different line, I would need the exact line. Maybe try with a debugger:

import pdb; pdb.set_trace()

(And then use pdb controls such as s, n, and c.)

The part with is not recognized as an internal or external command, operable program or batch file suggests that something is being run without python, when it should be run with python. Will need more info.

@ScriptKiddie-1234
Copy link
Author

Lightning-fast response!
To be clear, the issue is with
with SB(browser='chrome',uc=True) as sb:
the print() line works fine. So does everything else I tried from seleniumbase's methods.

Going thru with pdb, i spotted a few errors, but none from any files from this repo.

my only concern is the is not recognized as an internal or external command, operable program or batch file part... pdb didn't help narrow that down.

However, changing the line to with SB() as sb: resulted in only 1 is not recognized... spiel instead of the 3 from before.

As my username suggests, I'm not very good at this, so I really appreciate your patience.

@mdmintz
Copy link
Member

mdmintz commented Aug 11, 2023

I'll look into it, but it will certainly help if you can use pdb.set_trace() to find the exact lines where this is happening.

@ScriptKiddie-1234
Copy link
Author

It's technically not an error, so it's hard to find. I'll give this another go when I have more time and let you know.

Thanks for everything

@ScriptKiddie-1234
Copy link
Author

ScriptKiddie-1234 commented Aug 12, 2023

@mdmintz
So here's what I've learned:

  1. The is not recognized... terminal output occurs once with any argument except uc=True - then it outputs 3 times.
  2. With a new windows account without a whitespace in the name, the issue did not occur at all.
  3. pdb is super powerful, but perhaps I can't use it effectively to find the code that outputs that annoying line. Taking it step-by-step takes over 5 min just holding down the enter key (after s command)

@ScriptKiddie-1234
Copy link
Author

@mdmintz

The ...is not recognized as an internal or external command, operable program or batch file. (henceforth "errorLine") is referring to the drivers in the seleniumbase/drivers directory.

Deleting the drivers and running the script again did not output the errorLine - but did redownload the drivers to seleniumbase/drivers. I copied the new drivers to a directory that I have in my PATH (C:\WebDrivers - no whitespace) and deleted them again from seleniumbase/drivers and it downloaded them again (despite them supposedly being available and up-to-date).

Is there a way to set a preference for drivers in PATH over seleniumbase/drivers?

Another issue could be that seleniumbase is simply not detecting my installed drivers. Other modules seem to find them though...

@mdmintz
Copy link
Member

mdmintz commented Aug 13, 2023

I see the issue. It was with subprocess.check_output() when the path contains spaces. Quotes needed to be put around an entire path to not have it count as separate commands. The fix will be shipped in the next SeleniumBase release.

@mdmintz mdmintz added the bug Uh oh... Something needs to be fixed label Aug 13, 2023
@mdmintz mdmintz self-assigned this Aug 13, 2023
@ScriptKiddie-1234
Copy link
Author

For the time being, if anyone else is having the same issue, do the following:
in seleniumbase/core/browser_launcher.py, edit the following lines:

Line ~160:

Old: "%s --version" % LOCAL_UC_DRIVER, shell=True
New: f'"{LOCAL_UC_DRIVER}" --version', shell=True

Line ~2915:

Old: "%s --version" % LOCAL_CHROMEDRIVER, shell=True
New: f'"{LOCAL_CHROMEDRIVER}" --version', shell=True

if you are using a different browser or still getting the issue search for subprocess.check_output() as @mdmintz mentioned and do similar edits to the ones above.

@mdmintz
Copy link
Member

mdmintz commented Aug 13, 2023

This was resolved in 4.17.4 - https://github.com/seleniumbase/SeleniumBase/releases/tag/v4.17.4

@mdmintz mdmintz changed the title Question: Whitespace in Windows username causing non-critical error - Can I resolve this somehow? Whitespace in Windows username causing non-critical error - Can I resolve this somehow? Aug 13, 2023
@mdmintz mdmintz added the UC Mode Undetected Chromedriver Mode (--uc) label Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Uh oh... Something needs to be fixed question Someone is looking for answers UC Mode Undetected Chromedriver Mode (--uc)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants