7

.pyWindows bash コンソールを使用して、Visual Studio Code でpython ファイルを実行したいと考えています。

私がやろうとしたこと:

のデフォルト シェルを変更しますsettings.json

{
    "terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\bash.exe"
}

ファイル名を引数としてコマンドtasks.jsonを実行するタスクを追加します。python

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "0.1.0",
    "command": "python",
    "isShellCommand": true,
    "showOutput": "always",
    "tasks": [
        {
            "taskName": "Run python in bash",
            "suppressTaskName": true,
            "args": ["${file}"]
        }
    ]
}

ここで解決すべき問題がいくつかあります。

  1. タスクが希望どおりに bash で実行されていない
  2. Cドライブにアクセスするには、ファイルパスで置き換える必要があります C:\/mnt/c

それらの問題に対する私の解決策を共有できますか?

4

1 に答える 1

0

私は Windows 10 を持っていませんがbash、実際に Python を実行しようとしていないことが問題だと思います。あなたは実行しようとしていますbash(そして実行しようとしていますpython)。コマンドをbashwith paramsに設定してみてください["python", "$file"]

于 2016-09-28T18:55:48.127 に答える