Gmt: command not found in VS code with Mac OS 12.5

Hi all, I use the Version 6.4 of GMT with Mac OS 12.5 Monterey. When I run the code of the file "” like the code below in VS code, it will return to the results-- gmt: command not found. However, it works when I run the bash file in my own terminal. What’s going on, why doesn’t it recognise gmt commands?

#Code for
#!/usr/bin/env -S bash -e
#GMT modern mode bash template
#Date: 2022-10
#User: M***
#Purpose: Purpose of this script

export GMT_SESSION_NAME=$$ # Set a unique session name
gmt begin figurename png
gmt coast -Rg -JH15c -Gpurple -Baf -B+t"Kang First Plot" # Place modern session commands here
gmt end show

MacBook-Pro-3:GMT Mike$ bash line 7: gmt: command not found line 8: gmt: command not found line 9: gmt: command not found

please help me out,
Best regards.

Not a Mac user, but it sounds like VS Code does not include the path to the gmt executable. Try running which gmt in a terminal and find a way to add that path to VS Code.

I already solved this problem. You are right, set the right path to allow VS code use GMT is extremely important. But it will make beginners struggle with this step if you use GMT dmg package to install. Here is my suggestion, to install GMT by using Homebrew in your Mac terminal would be much easier, this is highly recommended. Thanks for your reply.

You don’t imagine how we wish there would be only one solution to install GMT.

Installing GMT (gmt6) with MacPorts also works well on Macs if you are using MacPorts for other packages.