在MacOs Python Shell中粘贴多行会返回SyntaxError

问题描述:

我必须重新安装MacBook.我从brew下载了python.

I had to reinstall my MacBook. I downloaded python from brew.

当我从brew中将代码复制并粘贴到python shell中时,文本将突出显示,并且代码未执行.

When I copy and paste code in the python shell from brew, the text is highlighted and the code not executed.

当我使用MacBook上的普通python时,没有问题.

When I use the stock python from my MacBook there is no problem.

请观看以下短片: https://youtu.be/CrTzBpVdcVM

我不是唯一遇到此问题的人,但是尚未找到解决方案:

I'm not the only one with this problem, however no solutions had been found yet:

在Python中粘贴多行时出现SyntaxError

>://python-forum.io/Thread-How-to-paste-several-lines-of-codes-to-the-Python-console

https://github.com/Homebrew/discussions/discussions/428

在readline中似乎有一个错误(自制软件用于安装python)

It seems that there is a bug in readline (which is used by homebrew to install python)

简短答案:回显设置启用包围式括号粘贴";>>〜/.inputrc

short answer: echo "set enable-bracketed-paste off" >> ~/.inputrc

长答案: https://github.com/Homebrew/homebrew-core/issues/68193