python2.7 from macports stdin issue

2

1

My python2.7 from macports seems to mess up with osx terminal in a weird way. Here is what I mean.

The exact input from the keyboard was:

/opt/local/bin/python2.7<ENTER>
a = 3<ENTER>
a<ENTER>
<CTRL+D>
/opt/local/bin/python2.7<ENTER>
a = 3<ENTER>
a<ENTER>
<CTRL+D><ENTER>
exit()<ENTER>
<ENTER>
ls

And here's what I saw in the terminal window:

Artems-MacBook-Pro-2 /Users/artem $ /opt/local/bin/python2.7
Python 2.7.10 (default, Aug 31 2015, 01:42:42) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 3
>>> a
>>> 3
a
>>> 3
^D>>> 
Artems-MacBook-Pro-2 /Users/artem $ Python 2.7.10 (default, Aug 31 2015, 01:42:42) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 3
>>> a
>>> 3
a
>>> 3
^D
>>> exit()
>>> Artems-MacBook-Pro-2 /Users/artem $ 
Artems-MacBook-Pro-2 /Users/artem $ ls

As you can see, the first weird thing happens when I try to print the value of 'a' for the first time, i.e. I get

>>> a
>>> 3
<cursor here>

instead of

>>> a
3
>>> <cursor here>

Then, after exiting from python for the first time no input is being shown in the terminal, i.e. I get:

Artems-MacBook-Pro-2 /Users/artem $ Python 2.7.10 (default, Aug 31 2015, 01:42:42)

instead of

Artems-MacBook-Pro-2 /Users/artem $ /opt/local/bin/python2.7
Python 2.7.10 (default, Aug 31 2015, 01:42:42)

The second python session keep behaving weirdly + the CTRL+D keys combination stops to work. After quitting from this second session the input is seen fine again in the terminal.

Does anyone have a clue why this is happening and how to fix it?

P.S. The default python from OSX doesn't have this issue, but I really want to make the macports version to work

SiLiKhon

Posted 2015-08-31T06:55:27.203

Reputation: 35

Answers

0

I fixed it by switching to a different python on my system:

$ sudo port select python python27-apple

Kurt

Posted 2015-08-31T06:55:27.203

Reputation: 16

1

Had the same issues -- really annoying! After reading http://bugs.python.org/issue24961, decided to try running

sudo port install py27-readline

...and it fixed the problem, at least on my machine. Probably someone should file a ticket with MacPorts...

Matt Zucker

Posted 2015-08-31T06:55:27.203

Reputation: 11

A ticket was filed a while ago. A fix should be coming soon. – fd0 – 2015-09-20T15:30:04.667

Interesting! Do you have the URL by any chance? – Matt Zucker – 2015-09-20T16:01:30.197

Thank you! I experienced exactly the same thing and the install of py27-readline fixed it. – Bogatyr – 2015-09-27T20:26:42.603

0

I had the same issue after installing matplotlib on Aug 29 this year. It drove me crazy, so I uninstalled it:

sudo port uninstall --follow-dependents python27 @2.7.10_3+universal

I think this specific macports version of Python is just broken.

marcelk

Posted 2015-08-31T06:55:27.203

Reputation: 1

0

I have identified that problem stems from ncurses. I don't have a fix, yet. I have software compiled with ncurses @5.9_2 and ncurses @6.0_0 which is raging havoc at the moment.

fd0

Posted 2015-08-31T06:55:27.203

Reputation: 1 222