0

This is a voice assistant, I'm trying to apply google maps although. An error appeared -
"The system cannot find the path specified."... I think the problem is the application location. How can I fix this?

Here is my code:

 if "where is" in data: listening = True data = data.split(" ") location_url = "https://www.google.com/maps/place/" + str(data[2]) respond("Hold on Sienan, I will show you where " + data[2] + " is.") maps_arg = '/usr/bin/open -a "C:/Program Files/Google/Chrome/Application/Google Chrome.app"' + location_url os.system(maps_arg) 

maps_arg = '/usr/bin/open -a "C:/Program Files/Google/Chrome/Application/Google Chrome.app"' + location_url

2
  • Please, for making good questions that can be addressed promptly by the community, provide a Minimal, Reproducible Example Commented Oct 15, 2021 at 2:30
  • you forgot space between '"... Chrome.app"' and location_url so it could create one long string and system may treat it as single value with path. You have to add space after closing " in "...Chrome.app" ' Commented Oct 15, 2021 at 3:12

2 Answers 2

0

Immediately I can see that the problem is indeed in the maps_arg line as /usr/bin/open is a directory found in Linux and not windows, try removing it and the - a leaving you with

maps_arg = "C:/Program\ Files/Google/Chrome/Application/chrome.exe {}".format(location_url) 

And IF that doesn't work try removing the double quotes around the path as well.

Sign up to request clarification or add additional context in comments.

7 Comments

An error appeared, 'C:\Program' is not recognized as an internal or external command, operable program or batch file.
I also tried maps_arg = 'C:/Program Files/Google/Chrome/Application/chrome.exe' + location_url
Try adding a \ before all of the spaces in the string and then try running that.
@AssistmeSenpai try the new string in the edited answer now.
I'd suggest using pathlib.Path to deal with paths and making sure they are consistent. Also, I believe subprocess (with Popen, for example) is best for executing commands -- see more in this question
|
0
if "where is" in data: listening = True data = data.split(" ") location_url = "https://www.google.com/maps/place/" + str(data[2]) respond("Hold on Sienan, I will show you where " + data[2] + " is.") webbrowser.open(location_url) 

1 Comment

I imported webbrowser

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.