Reputation: 129
Sometimes, when developing python code, I open a script in gedit and copy chunks of code into the python command line on Linux. This used to work just fine. For example, here are two commands which I copied together:
import numpy as np
import matplotlib.pyplot as plt
Today, however, I am getting the following error when I try to copy and execute multiple lines together:
SyntaxError: multiple statements found while compiling a single statement
This did not used to happen. Another difference is that my commands are highlighted white when I paste them into python. I feel like I must be missing something obvious. Any idea why I can't execute multiple lines together?
Upvotes: 2
Views: 2403
Reputation: 6786
This smells like it has something to do with "bracketed paste mode", especially with that highlighting going on. From a distance I can't tell what or how, though. Possibly related to this issue: https://bugs.python.org/issue42819 .
Upvotes: 2
Reputation: 4700
When you are trying to run code in the Python shell, you can only run one line of code (more specifically, one statement) at a time. You would have to execute each import
statement individually.
Upvotes: 0