I have a problem with my "b" letter in Python shell in OS X. I can't type "b", but "B" worked fine.
How can I solve this issue?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
The problematic line in your
.pythonstartup is something like:
readline.parse_and_bind("bind ^I rl_complete") # darwin libedit
.pythonstartup will fix it...
try: import readline except ImportError: print "Module readline not available." else: import rlcompleter if 'libedit' in readline.__doc__: readline.parse_and_bind("bind ^I rl_complete") else: readline.parse_and_bind("tab: complete")
First, this did not happen until I updated python 2.7.1 to 2.7.3. That said, the fix is on the line:
if(sys.platform == 'darwin'): #FIX
if(sys.platform == 'darwin') and 'libedit' in readline.__doc__: #FIX
The full code in my ~/.pythonrc
import atexit import os try: import readline except ImportError: print "Module readline not available." else: import rlcompleter import sys if(sys.platform == 'darwin') and 'libedit' in readline.__doc__: #FIX # OSX readline.parse_and_bind ("bind ^I rl_complete") else: # Linux readline.parse_and_bind("tab: complete") historyPath = os.path.expanduser("~/.pyhistory") def save_history(historyPath=historyPath): readline.write_history_file(historyPath) if os.path.exists(historyPath): readline.read_history_file(historyPath) atexit.register(save_history) del atexit, save_history, historyPath
I have the same issue. This happens when you use the MacPorts version of Python in Snow Leopard.
I don't see this issue in Apple's Python that comes with Mac OS X. So, the workaround should be to set
PYTHONPATH pointing to MacPorts' packages:
(or a different Python version) and use Apple's Python.
Unfortunately, the workaround is not a wise one.
Apple assumes that its version is unchanged when doing upgrades and other functions. Instead, it is recommended that if you wish to upgrade python or expand it that you install a local version, either under
/opt or your home folder.
I also have the same problem, and I do not use the MacPorts version of python.
I am using the latest version of
vpython, visual python, from www.vpython.org under Mac OX X Lion running in the latest MacBook Air (generation 3).
I installed vpython using their latest binary and using their instructions. It comes with an installer so it is point and click. This is a modified version of Python 2.7.1. It is 32 bit version. (I believe they have not ported it to 64 bits). I then installed VPython-Mac-Py2.7-5.71. I followed this by scipy from www.scipy.org and matplotlib from matplotlib.sourceforge.net All of these installations use an installer.
When I run python off their development tool, idle, or the vpython variant, vidle, I have no problems. If I open a terminal and run python from a bash shell, the shell will not recognize the "b" key in the keyboard. It will give you a 'bell' sound, instead of typing the 'character b'. However, you can enter the letter 'B'. Looks like this key is mapped to some incorrect non-displayed 'character', possibly the 'bell' character in old ASCII code.
I tried changing the emulation to xterm, vt100, vt102. I also played with different encoding schemes like just using UTF-8. I also pressed different combination of special keys like command-b etc. Nothing worked.
My only workaround is to write scripts off idle or vidle.
I hope this helps clarify the problem.