LoginSignup
15
6

More than 3 years have passed since last update.

【python】File "<stdin>", line 1のエラーの解決法

Posted at

現象

VSCodeでpythonを実行しようとしたところ、以下のようなエラーが出て実行できませんでした。

>>> /usr/local/bin/python /home/workspace/test/test.py
   File "<stdin>", line 1
    /usr/local/bin/python /home/workspace/test/test.py
    ^
SyntaxError: invalid syntax

デバッガーでは普通に実行できるし、
ターミナルを開いてコマンドラインから実行しても動く。

解決法

VSCodeのコンソールで、pythonが対話モードになったままだった。
なので、exit()で対話モードを抜けて、実行すると問題なく実行できました。

めでたしめでたし

15
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
6