IPython qtconsole highlighting - ipython

I am using the IPython qtconsole and the directories are dark blue and I can't seem to find any way to change this in the theme. I'm using pygments with the monokai theme for the syntax highlighting.

This coloring is actually done by ls itself.
You can use the LSCOLORS ( on OS X / BSD, or LS_COLORS on Linux) environment variable to customize this.
Here is a nifty utility for generating an LSCOLORS value.
You can probably Google-about for peoples favored dark-background LSCOLORS values.
Then just set the variable, either in Python:
import os
os.environ['LSCOLORS'] = 'gxfxcxdxbxegedabagacad'
or in your shell session prior to launching IPython (or .bashrc, etc.):
$> export LSCOLORS=gxfxcxdxbxegedabagacad
$> ipython qtconsole
see also: reference docs for LS_COLORS

Related

IPython tab completion menu colors are unreadable

Tab completion in IPython is practically unusable because the text is so difficult to read.
Here's what I've tried:
I didn't have an ipython configuration file so I created one:
ipython profile create.
In my ipython_config.py I set c.InteractiveShell.colors = 'NoColors'. That made all my text white but the completion text didn't change.
I'm using the following software:
kitty terminal: 0.14.1
IPython: 7.5.0
Pygments: 2.4.2
prompt-toolkit: 2.0.9
I found a solution. It seems my terminal is using 24bit color and that must be interacting poorly with the defaults of IPython which defaults to 256 colors. You can test your terminal with this command:
printf "\x1b[38;2;255;100;0mTRUECOLOR\x1b[0m\n"
If you see 'TRUECOLOR', then your terminal supports true color.
I set that in my ipython_config.py file: c.TerminalInteractiveShell.true_color = True. Now the completion text is readable.

Org-mode with Emacs: Where do I have to put my export in order to be able to use it in Emacs daemon?

I am struggling since this morning after the installation of CUDA 9 and cudnn 7. I am running emacs as a daemon, zsh as my default shell and I want to user org-mode to write notebook.
Here is my .zshenv:
...
export LIBRARY_PATH="/usr/include/gtk-3.0:$LIBRARY_PATH"
export LD_LIBRARY_PATH="/usr/local/cuda-9.0/lib64:$LD_LIBRARY_FOUND"
export PATH="/usr/local/cuda-9.0/bin:$PATH"
export SHELL="/bin/zsh"
export WORKON_HOME=$HOME/.virtualenvs
and here is the minimal notebook:
#+BEGIN_SRC ipython :results drawer :async t :session test
import os
print(os.environ["LD_LIBRARY_PATH"])
#+END_SRC
The problem is that emacs does not know LD_LIBRARY_PATH. It says KeyError.
Do you know where I can put my environment variables in order to be able to be read both by my terminal and Emacs-As-A-Daemon ? I thought it was in .zshenv and .zprofile but neither of them is working in daemon mode... (Because yes, it is working when I launch it regularly).
Precision:
The content of os.environ shows that it seems to read the .profile file only... But why ? My default terminal is zsh, not bash. I tried to put my export in .zprofile, restart systemd daemon of emacs, even rebooting, but without any effect.. Sorry if this is a silly question.
Alright, I succeed to solve my issue. Instead of dealing with Emacs configuration, I changed the systemd unit file with the addition of the EnvironmentFile variable which I set it equal to the path of my .zshenv:
EnvironmentFile=~/.zshenv

Enabling vi key bindings in IPython qtconsole

I have enabled vi mode in my ~/.inputrc using the following lines in my mac.
set editing-mode vi
When I use IPython in terminal, I am getting proper vi key bindings, but when I use IPython in QtConsole using the command ipython qtconsole the vi key bindings don't work.
Is there anything else I have to do to get vi key bindings in IPython QtConsole?
Qt console is not built around readline or anything related to the OS terminal. It's a Qt widget that mimics much of the behavior of terminal IPython and also has several cool features of its own (like inline plots and the ability to render Latex).
It comes with a lot of key bindings (which you can find by going to the menu Help > Show QtConsole Help) but unfortunately none of them is customizable.

Stop ipython pop-up docs

In the ipython qtconsole it automatically displays the documentation for a function when I type the opening parenthesis. For example, when I'm typing
plt.show()
the documentation for pyplot.show is displayed when I've typed
plt.show(
This documentation is displayed in a pop-up window that, much more often than not, blocks my view what I'm typing. Is there a configuration to stop the ipython qtconsole from doing this?
The feature to which you refer is calltips or more precisely IPythonWidget.enable_calltips and is documented at https://ipython.org/ipython-doc/dev/config/options/qtconsole.html. The only effective way I have found to disable it is by adding --IPythonWidget.enable_calltips=False as an argument to qtconsole that in turn an argument of ipython. A command line for all of this is:
ipython qtconsole --IPythonWidget.enable_calltips=False
I have verified this with IPython QTConsole 3.2.0 and believe it generally works for versions below 4, which I have not been able to install yet without breaking QTConsole. (I believe what some refer to as IPython 4 is also known as Jupyter 4. See below for information on Jupyter and disabling calltips in it.)
On Linux and Windows system, generating this command line can be automated using a bash alias. On Windows it can be automated by using it as the Target of an icon configured in its properties.
It is supposed to be possible to disable calltips by setting c.IPythonWidget.enable_calltips = False in the right configuraton file in which c = get_config() is set on the first line. I tried doing this on a Windows 7 system in ipython_qtconsole_config.py and ipython_config.py in ~.ipython\profile_default\ and several other locations, but could not get it to work.
Project Jupyter is the successor to the IPython project and began in 2014. Its website is http://jupyter.org and information about its Qt console is at http://jupyter.org/qtconsole/stable/index.html. In response to a question about disabling IPython calltips, which I submitted to https://github.com/ipython/ipython/issues, I received the following on how to disable calltips for Jupyter:
On the command line
jupyter qtconsole --JupyterWidget.enable_calltips=False
or add
c.JupyterWidget.enable_calltips = False
to
~/.jupyter/juptyer_qtconsole_config.py

Display of music21, musicXML PNG objects using iPython Notebook/Enthought Canopy

I am experimenting with the music21 library, in preparation for a Machine Learning project that involves genre classification and categorization. I and following some tutorials available here. I am using MuseScore as my MusicXML program, and I am trying to run the whole thing from iPython.
Although I can run the some of the turtorials from the terminal, some elements don't seem to run well from inside iPython. For example:
In [3]: sBach.show()
Out[3]: <music21.ipython21.objects.IPythonPNGObject at 0x10da0aa10>
The line above shows that the PNG object is created, but not displayed. The expected output for 3 above is the following:
Experimenting with the following iPython command, I get a placeholder for an image, but not image.
In [6]: %load_ext music21.ipython21.ipExtension
In [7]: sBach.show()
I can't find any problem with my MusicXMLPath. This tutorial refers to the use of musc21 with Anaconda, but all my developments is done with Enthought, so I prefer not to run another virtual environment to use music21 with iPython.
Is there any way to run music21 in an Enthought/iPython notebook?
I have been grappling with this issue myself. ... Have you set your musicxmlPath in music21? If you have not, it's done via environment.set(key, value). You can query for available keys with environment.keys(). I hope this isn't too simple an answer, but it cleared up the problem for me.
This should be in the iPython music21 documentation somewhere, my apologies: iPython in music21 requires Lilypond to be installed for images to be generated within the notebook itself. There hasn't been (and won't be until MuseScore 2.0 is released) a way using MusicXML to generate PNG images of scores directly.
Edit: 2015 July; music21 2.0 w/ MuseScore 2 will generate the PNG images with MuseScore if it is installed and fallback to Lilypond if it is not installed.
If not yet tried, some steps to isolate the cause of the problem:
1) Update to the latest Canopy (Edit: currently 1.4.1) (might help this, will help generally, won't hurt).
2) Change the Pylab backend in Canopy's IPython shell to "Inline (SVG)", via Preferences / Python. (The default Qt backend in that shell conflicts with music21's use of the tkinter library.)
3) Test your script in that shell rather than in the notebook.
4) Ensure that Canopy User Python is your default Python in a Terminal window, as described here.
5) Test your scripts inside of plain ipython terminal (from Terminal, type ipython).
6) Test in ipython terminal in pylab mode (ipython qtconsole --pylab=inline).
7) Test your scripts inside of ipython notebook running in a regular browser (from Terminal, type ipython notebook, and/or ipython notebook --pylab=inline).
Had similar issues before. It's the same problem when people try to use plot function in ipython/jupyter notebook. You need to call
%matplotlib inline
For me the issue was solved by uninstalling the snap version of musescore and installing it from ppa:mscore-ubuntu/mscore3-stable via https://launchpad.net/~mscore-ubuntu/+archive/ubuntu/mscore3-stable