VisualStudioCodeを使って、パスを指定して実行する
launch.jsonにpythonPathの項目を追加すればOK
pyまで入力すればpythonPathが候補で出てきます
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
"pythonPath": "/opt/anaconda3/bin/python.app"
}
]
pythonのパスがどこか探すのはFinderで検索かけるしかないのかな?
launch.jsonの作成は、pythonの拡張をインストールしてからRun(虫マーク)へ行って作れる。
昔は歯車マークがあったけど、構成ファイル作ってからじゃないと歯車マーク出てこないっぽい。
20211028追記
pythonPathの項目がいつの間にかなくなりました。
ユーザー設定でpython Default Interpreter Pathにpython.exeのフルパスを入力する方法がよさそうです。
フルパスの取得は
import sys
path = sys.executable
print(path)
で可能です