PyxelというPythonプログラムをVSCode上で実行したい
以下のプログラムの、サンプルプログラム「01_hello_pyxel.py」をVSCodeで実行しようとしたところ、エラーが発生し実行することができません。
https://github.com/kitao/pyxel
PowerShellでは実行できたのになぜでしょうか?
発生している問題・エラーメッセージ
例外が発生しました: FileNotFoundError [Errno 2] No such file or directory: 'c:\Users\[ユーザー名]\.vscode\extensions\ms-python.python-2018.11.0\pythonFiles\experimental\assets/pyxel_logo_38x16.png' File "C:\Users[ユーザ名]\Downloads\Pyxel\pyxel_examples\01_hello_pyxel.py", line 6, in __init__ pyxel.image(0).load(0, 0, "assets/pyxel_logo_38x16.png") File "C:\Users[ユーザ名]\Downloads\Pyxel\pyxel_examples\01_hello_pyxel.py", line 18, in <module> App()
該当のソースコード
Python
1import pyxel 2 3 4class App: 5 def __init__(self): 6 pyxel.init(160, 120, caption="Hello Pyxel") 7 pyxel.image(0).load(0, 0, "assets/pyxel_logo_38x16.png") 8 pyxel.run(self.update, self.draw) 9 10 def update(self): 11 if pyxel.btnp(pyxel.KEY_Q): 12 pyxel.quit() 13 14 def draw(self): 15 pyxel.cls(0) 16 pyxel.text(55, 41, "Hello, Pyxel!", pyxel.frame_count % 16) 17 pyxel.blt(61, 66, 0, 0, 0, 38, 16) 18 19 20App()
試したこと
ダウンロードしたPyxelプログラムのフォルダをVSCodeで開き、「01_hello_pyxel.py」を実行した
VSCodeのlaunch.json
情報追加したほうがよいとの指摘があったため、VSCodeのlaunch.jsonを補足させていただきます。launch.jsonってこれのことでしょうか?よろしくお願いします。
######launch.json
json
1{ 2 // IntelliSense を使用して利用可能な属性を学べます。 3 // 既存の属性の説明をホバーして表示します。 4 // 詳細情報は次を確認してください: https://go.microsoft.com/fwlink/?linkid=830387 5 "version": "0.2.0", 6 "configurations": [ 7 { 8 "name": "Python: Current File (Integrated Terminal)", 9 "type": "python", 10 "request": "launch", 11 "program": "${file}", 12 "console": "integratedTerminal" 13 }, 14 { 15 "name": "Python: Attach", 16 "type": "python", 17 "request": "attach", 18 "port": 5678, 19 "host": "localhost" 20 }, 21 { 22 "name": "Python: Module", 23 "type": "python", 24 "request": "launch", 25 "module": "enter-your-module-name-here", 26 "console": "integratedTerminal" 27 }, 28 { 29 "name": "Python: Django", 30 "type": "python", 31 "request": "launch", 32 "program": "${workspaceFolder}/manage.py", 33 "console": "integratedTerminal", 34 "args": [ 35 "runserver", 36 "--noreload", 37 "--nothreading" 38 ], 39 "django": true 40 }, 41 { 42 "name": "Python: Flask", 43 "type": "python", 44 "request": "launch", 45 "module": "flask", 46 "env": { 47 "FLASK_APP": "app.py" 48 }, 49 "args": [ 50 "run", 51 "--no-debugger", 52 "--no-reload" 53 ], 54 "jinja": true 55 }, 56 { 57 "name": "Python: Current File (External Terminal)", 58 "type": "python", 59 "request": "launch", 60 "program": "${file}", 61 "console": "externalTerminal" 62 } 63 ] 64}