Mac vscode Python構成
9641 ワード
コンフィギュレーションエディタ
1.基礎設定settings.json
VSコードにはエディタを構成するオプションがたくさんあります.ユーザー設定でグローバルオプションを設定したり、ワークスペース設定でフォルダやプロジェクトごとに設定したりして、オプション設定をsettingsに保存することができます.jsonファイルにあります.
Files>Preferences>User Settings(またはkb(workbench.action.showCommands)を押してuserを入力Enterを押してsettingsを編集する.jsonファイル
Files>Preferences>Workspace Settings(またはkb(workbench.action.showCommands)を押す、workspを入力してEnterを押す)を押してワークスペースのsettingsを編集する.jsonファイル
VSコードのデフォルト設定が左側のウィンドウにあり、編集したsettingsが表示されます.jsonは右側にあります.デフォルト設定から設定を表示およびコピーするだけです.
設定編集が完了したら、kb(workbench.action.files.save)を入力して変更を保存し、変更はすぐに有効になります.
settings.json
2.プロファイルlaunchをデバッグする.json
launch.json
3.タスク構成(直接実行構成)tasks.json
tasks.json
1.基礎設定settings.json
VSコードにはエディタを構成するオプションがたくさんあります.ユーザー設定でグローバルオプションを設定したり、ワークスペース設定でフォルダやプロジェクトごとに設定したりして、オプション設定をsettingsに保存することができます.jsonファイルにあります.
Files>Preferences>User Settings(またはkb(workbench.action.showCommands)を押してuserを入力Enterを押してsettingsを編集する.jsonファイル
Files>Preferences>Workspace Settings(またはkb(workbench.action.showCommands)を押す、workspを入力してEnterを押す)を押してワークスペースのsettingsを編集する.jsonファイル
VSコードのデフォルト設定が左側のウィンドウにあり、編集したsettingsが表示されます.jsonは右側にあります.デフォルト設定から設定を表示およびコピーするだけです.
設定編集が完了したら、kb(workbench.action.files.save)を入力して変更を保存し、変更はすぐに有効になります.
settings.json
{
"python.pythonPath": "/usr/local/opt/python3/bin/python3.6"
}
2.プロファイルlaunchをデバッグする.json
launch.json
{
// IntelliSense 。
// 。
// , : https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config:python.pythonPath}",
"program": "${file}",
"cwd": "${workspaceRoot}",
"env": {},
"envFile": "${workspaceRoot}/.env",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
]
},
{
"name": "Python: Attach",
"type": "python",
"request": "attach",
"localRoot": "${workspaceRoot}",
"remoteRoot": "${workspaceRoot}",
"port": 3000,
"secret": "my_secret",
"host": "localhost"
},
{
"name": "Python: Terminal (integrated)",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config:python.pythonPath}",
"program": "${file}",
"cwd": "",
"console": "integratedTerminal",
"env": {},
"envFile": "${workspaceRoot}/.env",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit"
]
},
{
"name": "Python: Terminal (external)",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config:python.pythonPath}",
"program": "${file}",
"cwd": "",
"console": "externalTerminal",
"env": {},
"envFile": "${workspaceRoot}/.env",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit"
]
},
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config:python.pythonPath}",
"program": "${workspaceRoot}/manage.py",
"cwd": "${workspaceRoot}",
"args": [
"runserver",
"--noreload",
"--nothreading"
],
"env": {},
"envFile": "${workspaceRoot}/.env",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput",
"DjangoDebugging"
]
},
{
"name": "Python: Flask (0.11.x or later)",
"type": "python",
"request": "launch",
"stopOnEntry": false,
"pythonPath": "${config:python.pythonPath}",
"program": "fully qualified path fo 'flask' executable. Generally located along with python interpreter",
"cwd": "${workspaceRoot}",
"env": {
"FLASK_APP": "${workspaceRoot}/quickstart/app.py"
},
"args": [
"run",
"--no-debugger",
"--no-reload"
],
"envFile": "${workspaceRoot}/.env",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
]
},
{
"name": "Python: Flask (0.10.x or earlier)",
"type": "python",
"request": "launch",
"stopOnEntry": false,
"pythonPath": "${config:python.pythonPath}",
"program": "${workspaceRoot}/run.py",
"cwd": "${workspaceRoot}",
"args": [],
"env": {},
"envFile": "${workspaceRoot}/.env",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
]
},
{
"name": "Python: PySpark",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"osx": {
"pythonPath": "${env:SPARK_HOME}/bin/spark-submit"
},
"windows": {
"pythonPath": "${env:SPARK_HOME}/bin/spark-submit.cmd"
},
"linux": {
"pythonPath": "${env:SPARK_HOME}/bin/spark-submit"
},
"program": "${file}",
"cwd": "${workspaceRoot}",
"env": {},
"envFile": "${workspaceRoot}/.env",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
]
},
{
"name": "Python: Module",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config:python.pythonPath}",
"module": "module.name",
"cwd": "${workspaceRoot}",
"env": {},
"envFile": "${workspaceRoot}/.env",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
]
},
{
"name": "Python: Pyramid",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config:python.pythonPath}",
"cwd": "${workspaceRoot}",
"env": {},
"envFile": "${workspaceRoot}/.env",
"args": [
"${workspaceRoot}/development.ini"
],
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput",
"Pyramid"
]
},
{
"name": "Python: Watson",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config:python.pythonPath}",
"program": "${workspaceRoot}/console.py",
"cwd": "${workspaceRoot}",
"args": [
"dev",
"runserver",
"--noreload=True"
],
"env": {},
"envFile": "${workspaceRoot}/.env",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
]
}
]
}
3.タスク構成(直接実行構成)tasks.json
tasks.json
{
"version": "0.1.0",
"command": "python3",
"isShellCommand": true,
"args": ["${file}"],
"showOutput": "always"
}