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

Bob
  • 43
  • 6
  • Please, for making good questions that can be addressed promptly by the community, provide a [Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) – MatBBastos Oct 15 '21 at 02: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" '` – furas Oct 15 '21 at 03:12

2 Answers2

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.

Masterbond7
  • 99
  • 11
  • An error appeared, 'C:\Program' is not recognized as an internal or external command, operable program or batch file. – Bob Oct 15 '21 at 00:59
  • I also tried maps_arg = 'C:/Program Files/Google/Chrome/Application/chrome.exe' + location_url – Bob Oct 15 '21 at 01:01
  • Try adding a \ before all of the spaces in the string and then try running that. – Masterbond7 Oct 15 '21 at 01:56
  • @AssistmeSenpai try the new string in the edited answer now. – Masterbond7 Oct 15 '21 at 02:07
  • 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](https://stackoverflow.com/questions/4813238/difference-between-subprocess-popen-and-os-system) – MatBBastos Oct 15 '21 at 02:28
  • Thanks senpai, but it still didn't work... Same error occured "C:\Program/ is not recognized as an internal or external command, operable program or batch file". – Bob Oct 15 '21 at 02:37
  • But I was able to find a different solution – Bob Oct 15 '21 at 02:37
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)
Bob
  • 43
  • 6