latorrefabian
latorrefabian

Reputation: 1107

Mac Terminal Strange Behaviour (no newline when hitting enter, no visible text )

I'm on Mac OS X 10.11.3 My terminal looks like this:

[Fabian@MacBook-Pro] > 
[Fabian@MacBook-Pro] > pyspark
Python 2.7.11 (default, Jan 29 2016, 17:48:19) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
16/03/17 10:08:22 WARN NativeCodeLoader: Unable to load native-hadoop library     for your platform... using builtin-java classes where applicable
Welcome to

      ____              __
     / __/__  ___ _____/ /__
    _\ \/ _ \/ _ `/ __/  '_/
   /__ / .__/\_,_/_/ /_/\_\   version 1.6.1
      /_/

Using Python version 2.7.11 (default, Jan 29 2016 17:48:19)
SparkContext available as sc, HiveContext available as sqlContext.
>>> print 'hello'
>>> hello

>>> quit()
>>> [Fabian@MacBook-Pro] > [Fabian@MacBook-Pro] > [Fabian@MacBook-Pro] > [Fabian@MacBook-Pro] > -bash:     printsf: command not found

in the first line I press enter, and as you see, the prompt starts at another line, then I launch pyspark, do something and quit, then when I return to the prompt I press enter and as you can see, the prompt doesn't appear in a newline! I actually type and nothing is printed to the screen, however the commands are executed as you can see

 -bash:     printsf: command not found

my .bash_profile (located in /Users/Fabian folder) looks like this

# Setting PATH for Python 3.4
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.4/bin:${PATH}"
export PATH
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export PYTHONPATH=$PYTHONPATH:/Users/Fabian/Library/Python

##
# Your previous /Users/Fabian/.bash_profile file was backed up as /Users/Fabian/.bash_profile.macports-saved_2016-02-07_at_11:26:24
##

# MacPorts Installer addition on 2016-02-07_at_11:26:24: adding an appropriate PATH variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
# Finished adapting your PATH environment variable for use with MacPorts.

export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$PATH:/Users/Fabian/apache-maven-3.3.9/bin
export PS1="[\u@\h] > "
export PATH=$PATH:/Users/Fabian/spark-1.6.1-bin-hadoop2.6/bin

How Can I fix this behavior?? Thanks!

Upvotes: 11

Views: 12565

Answers (3)

sdh
sdh

Reputation: 1

I had the same problem with python 2.7.12 installed with macport. This might have been a coincidence, because I've tried many things, but "sudo port install py27-readline" fixed the problem for me.

Upvotes: 0

Thomas Dickey
Thomas Dickey

Reputation: 54583

As noted in comments (and as described by OP), the expected newline after each message was lost. That is because the application changed the terminal I/O modes dealing with carriage-return / line-feed, e.g.,

  • pressing Enter (which is a carriage return) was not translated into a newline (actually a line-feed), and
  • newlines sent from the computer were not translated into carriage return / line-feed.

However, on "any" keyboard, you can type a newline by pressing controlJ. The usual fixes apply pressing controlJ first to get a prompt, and completing the command with pressing controlJ):

  • stty sane (resets the terminal driver)
  • reset (resets the terminal driver as well as asking the terminal to reset itself).

Upvotes: 27

DaKnOb
DaKnOb

Reputation: 587

This can be caused by an escape character that when printed to the terminal causes it to go nuts. It usually helps if you close this terminal window and open a new one. Maybe pyspark is using some escape codes (for color or design) and then forgets to revert its changes. You can try running pyspark with a terminal type of dumb instead of xterm-256color. This can be done via the $TERM Environment Variable. Try doing echo $TERM before running pyspark.

Upvotes: 0

Related Questions