반응형
VSCode에서 python3 코드를 실행하는 방법? /bin/sh: 1: python: 찾을 수 없음
나는 python3를 사용하여 vcode에서 python 파일을 실행하려고 한다.
나는 온 파이썬에서 말하는 것처럼 단순히 실행하도록 설정하는 것으로 고칠 수 있다는 것을 안다. 그러나 프로그램이 터미널 창을 차지하지 않고 에서 인쇄하기를 원합니다.
표준 구성 파일은 다음과 같습니다;
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
VSCode에서 파이썬 경로를 설정하려고 했습니다
...
"python.pythonPath": "python3",
"code-runner.executorMap": {
"python3": "/usr/bin/python3"
}
나는 또한 python -> python3에 대한 별칭을 설정했다 (내 ubuntu 20.04는 python2와 함께 제공되지 않기 때문에)
alias python="python3"
그런데 위와 같은 오류가 계속 발생합니다. 아이디어가 있나요?
거의 다 됐어요. 이 코드
"python.pythonPath": "python3",
"code-runner.executorMap": {
"python3": "/usr/bin/python3"
}
그래야 한다
"python.pythonPath": "python3",
"code-runner.executorMap": {
"python": "/usr/bin/python3"
}
(차이는 3호선 시작 부분에 있습니다)
대체 솔루션
"python.pythonPath": "python3",
"code-runner.executorMap": {
"python": "$pythonPath -u $fullFileName"
},
vscode 단말기에 를 입력합니다. 설치가 완료되면 코드를 다시 실행하여 즐기십시오.
나중에 나오는 것들은, 만약 당신이 Code Runner를 설치했다면, 당신은 Code-runner로 들어가서 설정으로 들어가야 한다: 실행자 맵 "Edit in settings.json"을 지정하고 파이썬 섹션을 찾습니다
{
"workbench.colorTheme": "Default Dark+",
"code-runner.executorMap": {
"javascript": "node",
"java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
"c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"php": "php",
"python": "python -u",
"perl": "perl",
"perl6": "perl6",
"ruby": "ruby",
"go": "go run",
"lua": "lua",
"groovy": "groovy",
"powershell": "powershell -ExecutionPolicy ByPass -File",
"bat": "cmd /c",
"shellscript": "bash",
"fsharp": "fsi",
"csharp": "scriptcs",
"vbscript": "cscript //Nologo",
"typescript": "ts-node",
"coffeescript": "coffee",
"scala": "scala",
"swift": "swift",
"julia": "julia",
"crystal": "crystal",
"ocaml": "ocaml",
"r": "Rscript",
"applescript": "osascript",
"clojure": "lein exec",
"haxe": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt",
"rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt",
"racket": "racket",
"scheme": "csi -script",
"ahk": "autohotkey",
"autoit": "autoit3",
"dart": "dart",
"pascal": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
"d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt",
"haskell": "runhaskell",
"nim": "nim compile --verbosity:0 --hints:off --run",
"lisp": "sbcl --script",
"kit": "kitc --run",
"v": "v run",
"sass": "sass --style expanded",
"scss": "scss --style expanded",
"less": "cd $dir && lessc $fileName $fileNameWithoutExt.css",
"FortranFreeForm": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"fortran-modern": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"fortran_fixed-form": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"fortran": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt"
}
}
이것을 바꾸다
"python": "python -u",
아니면 이렇게 보이도록 비슷한 것
"python": "python3",
이것은 파이썬 3에서 파이썬 코드를 실행하기 위한 새로운 명령이기 때문이다
2023년 솔루션
1단계 : Code Runner 확장 설정으로 이동
2단계: 섹션 찾기
코드러너: 실행자 맵
그리고 클릭하세요
settings.json에서 편집
3단계 : 이제 python의 설정을 변경합니다
전에
"code-runner.executorMap": {
...
"python": "python -u"
...
}
다음으로 변경
"code-runner.executorMap": {
...
"python": "python3 -u"
...
}
sudo apt install python-is-python3
위의 명령줄을 입력하면 작동합니다.
반응형
'개발하자' 카테고리의 다른 글
TypeScript 선언(*.d.ts 파일)으로 JSON 파일 가져오기 (0) | 2023.01.08 |
---|---|
Jupyter Lab에서 찾고 교체하는 방법 (0) | 2023.01.07 |
빌드\app\outputs\apk\app.apk 설치 시 플러터가 고착됨 (0) | 2023.01.06 |
Fluter SDK 다운그레이드 방법(Dart 1.x) (0) | 2023.01.05 |
NLTK python 오류: "TypeError: 'dict_keys' 개체를 구독할 수 없습니다." (0) | 2023.01.05 |