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

[Question]: 'c:\Users\ASUS' is not recognized as an internal or external command, operable program or batch file. #1561

Closed
amuza2 opened this issue Sep 22, 2022 · 18 comments · Fixed by microsoft/playwright#17579 or microsoft/playwright#19801
Assignees

Comments

@amuza2
Copy link

amuza2 commented Sep 22, 2022

Your question

Peace, hi
1- created a virualenv
2- installed successfully playwright by "pip install playwright"
3- try to install playwright driver by "playwright install"

it gives me this output:
'""c:\Users\ASUS' is not recognized as an internal or external command,
operable program or batch file.

python version 3.10.6

@rwoll
Copy link
Member

rwoll commented Sep 22, 2022

This looks like the same issue from #1355 (comment). If so, can you try the suggested fix there?

@rwoll rwoll added the triaging label Sep 22, 2022
@amuza2
Copy link
Author

amuza2 commented Sep 22, 2022

This looks like the same issue from #1355 (comment). If so, can you try the suggested fix there?

unfortunately, it doesn't work.

@rwoll
Copy link
Member

rwoll commented Sep 23, 2022

Can you try installing another python package (e.g. https://docs.pytest.org/en/7.1.x/getting-started.html)? If that CLI command (pytest --help) doesn't work and gives you the same error, this points to a problem with your Python installation instead of PW itself.

@rwoll
Copy link
Member

rwoll commented Sep 23, 2022

in addition to the above, please also try python -m playwright install and let us know the output.

@amuza2
Copy link
Author

amuza2 commented Sep 23, 2022

pytest --help

installing other python packages work
==> python -m playwright install
the above installation doesn't work

but I found something weird
I uninstalled playwright and then wrote "playwright install" the output was:
'playwright' is not recognized as an internal or external command,
operable program or batch file.

then I installed it and run "pip install playwright" then "playwright install" I got this output:
'""c:\Users\ASUS' is not recognized as an internal or external command,
operable program or batch file.

it looks it's searching for "c:\Users\ASUS" instead of "playwright"
any idea

@rwoll
Copy link
Member

rwoll commented Sep 23, 2022

I'm not sure. Are there any spaces in the directory names along the path to your virtual env? Rather, what's the full path to your venv?

@amuza2
Copy link
Author

amuza2 commented Sep 23, 2022

I'm not sure. Are there any spaces in the directory names along the path to your virtual env? Rather, what's the full path to your venv?

I found the solution
I noticed this "'""c:\Users\ASUS'" it stopped at ASUS and my user folder name were "ASUS VIVOBOOK 17"
so right after ASUS there is a space, may be the space caused the problem and I did change the user name folder and it worked.
steps to solve this problem:
1- Change user folder name using a youtube video, it has several steps:
How To Change User Folder Name in Windows 10
https://www.youtube.com/watch?v=Y5_Q2BmTx3Y

2- Go change the python path, change the user folder name from the old to the new one.
you can enter this in your cmd as a shortcut
rundll32.exe sysdm.cpl,EditEnvironmentVariables

3- now you need just to use "python -m playwright install"

@amuza2
Copy link
Author

amuza2 commented Sep 24, 2022

I think changing the user folder name will have some new issues because a lot of tools or softwares that are set to the old user folder name. like for example changing export to some tools to the new.

@amuza2
Copy link
Author

amuza2 commented Sep 26, 2022

I found the solution I noticed this "'""c:\Users\ASUS'" it stopped at ASUS and my user folder name were "ASUS VIVOBOOK 17" so right after ASUS there is a space, may be the space caused the problem and I did change the user name folder and it worked. steps to solve this problem: 1- Change user folder name using a youtube video, it has several steps: How To Change User Folder Name in Windows 10 https://www.youtube.com/watch?v=Y5_Q2BmTx3Y

But in the case you installed your Python 3.10.x for all users, will you change the Program Files to ProgramFiles (with out space) ???

I tried to uninstall then install, it didn't work
maybe but my path is not in "program files" it's in "AppData" folder, this is my path:
"C:\Users\REALMAN\AppData\Local\Programs\Python\Python310\python.exe"
so there is no space

@amuza2
Copy link
Author

amuza2 commented Sep 26, 2022

Okay now I found the end of problem is from playwright driver. So the right solution is edit the playwright.cmd in a path which as the same as "C:\Program Files\Python310\Lib\site-packages\playwright\driver\playwright.cmd" with this content:

@echo OFF
SETLOCAL
IF %PLAYWRIGHT_NODEJS_PATH%x == x SET PLAYWRIGHT_NODEJS_PATH="%~dp0\node.exe"
""%PLAYWRIGHT_NODEJS_PATH%"" "%~dp0\package\lib\cli\cli.js" %*

Which I did is double quotes again the PLAYWRIGHT_NODEJS_PATH to fix the space error.

I saw that file but I didn't open it, I wouldn't even know what to do if I opened it anyway.
Congratulation

@amuza2
Copy link
Author

amuza2 commented Sep 26, 2022

"C:\Users\REALMAN\AppData\Local\Programs\Python\Python310\Lib\site-packages\playwright\driver\playwright.cmd"

I already solved the problem when I changed the user folder name from "asus vivobook 17" to "realman"
I am not going to touch anything, if it's working don't touch it :)

@hylkepostma
Copy link

Using Playwright (1.29.0, Python 3.10.2 on Windows 11) from C:\Program Files (x86)\My App Name With Spaces\ raises the following error:

AttributeError: 'PlaywrightContextManager' object has no attribute '_playwright'

I have changed the [...]Lib\site-packages\playwright\driver\playwright.cmd file so that it contains the following:

@echo off
setlocal
if not defined PLAYWRIGHT_NODEJS_PATH (
  set PLAYWRIGHT_NODEJS_PATH="%~dp0\node.exe"
)
""%PLAYWRIGHT_NODEJS_PATH%"" "%~dp0\package\lib\cli\cli.js" %*

After that, the error went away, so I can confirm that @funnydevdotvn's solution works for me. Thanks! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants