Cannot locate json connection file created by ipython kernel - ipython

I'm using ipython 4.1.2 (installed via Anaconda). I locate the profile location (which is the default)
ipython locate profile
/home/myname/.ipython/profile_default
ipython kernel runs fine, saying
To connect another client to this kernel, use:
--existing kernel-8664.json
However, when I look inside /home/myname/.ipython/profile_default/security, it is entirely empty.
What's the issue here?

Connection files now live in a different location, because they are a component of the Jupyter architecture, rather than an IPython specific thing. The exact location depends on your system, but you can find it by running:
jupyter --runtime-dir
Or in Python code, call:
jupyter_core.paths.jupyter_runtime_dir()

Related

Setting up jupyter kernel in remote VSCode notebook

I am trying to run some notebooks in my virtual environment in the VSCode (remotely connected). I install the venv as usual via python3 -m venv <venv-name>, activate it and install all the needed modules. When I run which ipython I get the one from the venv so I install the kernel via ipython kernel install --name "<name>" --user and it is successfully created in ~/.local/share/jupyter/kernels/ directory and the kernel.json points to the venv python. Then I open the VSCode and select both the Python: Select Interpreter and Jupyter: Select Interpreter to start Jupyter server to point to the virtual environment's python, sth. like .../<venv-name>/bin/python3.
However, when I try to run the cell it wants me to select kernel (I can also do it myself in the upper right corner of the VSCode), but my newly created kernel is not there. There are only two (same) ones from usr/bin/python.
It is really strange since twice in two days my kernel magically appeared for one notebook and worked as desired, but when I opened a new notebook, my kernel was gone again. I tried to remove/reinstall kernels, venvs, VSCode's Python and Jupyter extensions but nothing helped. Any suggestions?
For now, I start the kernel in remote command-line via jupyter notebook --no-browser --ip=<ip> and then insert the connection link to Jupyter Server in the bottom right corner of the VSCode status bar but am wondering if there is an easier way since all the stuff (except VSCode) is on a remote machine?
This way is not easy. You can set up Jupyter Kernel easily.
Firstly, using ssh to connect to the remote server.
Secondly, open Command Palette (⇧⌘P) and enter Python: Select Interpreter, you can directly connecting to remote kernel.
resource: https://code.visualstudio.com/docs/datascience/jupyter-notebooks

Jupyter Python logo

Does anyone know how to add Python logo to the top right corner of python notebooks in Jupyter ?
I see Ruby notebooks are added w/ Ruby logo automatically.
Can this be done in Python notebooks ?
Zarak, This is what I see
$ jupyter kernelspec list
Available kernels:
python2 d:\Continuum\Anaconda2\lib\site-packages\ipykernel\resources
ruby d:\eclipse\.ipython\kernels\ruby
$ pwd
/d/Continuum/Anaconda2/lib/site-packages/ipykernel/resources
$ ls
logo-32x32.png logo-64x64.png
This is NOT a solution, but an amelioration of the problem...
I had (still do) similar issue on my OS X 10.7. In my case, jupyter's python kernel, while not able to find logo-64x64.png file, would auto-redirect me to 404 page as soon as Notebook loads - so I was not able to use Notebooks at all.
If anyone else is having similar issue, I suggest to try any of the following steps (until you can use Notebook again). I still see 404 GET /kernelspecs/Python%20[Root]/logo-64x64.png message in Terminal - however, now I do not get redirected to 404 page automatically upon loading the Notebook.
initially I was using Firefox as default browser, however I switched to Chrome.
initially I only had kernel for python2.7 installed. Now I added kernel for python3.
I generally call jupyter with --notebook-dir argument. I copied into the folder I specify in that argument - the files from location, which I get by running jupyter kernelspec list (2 logo files and 1 json file)
In the end, I still have the same issue - and I am anxiously waiting for somebody else to respond with a solution. However, hope this helps some people in the meantime.

How to run qtconsole connected to ipython3 instance?

When I run %qtconsole from within ipython3 I get ERROR: Line magic function%qtconsolenot found., but ipython3 qtconsole in terminal starts fine. According to this, how can I run qtconsole instance connected to ipython3 instance? And how to run it on a single core -- rc[0].execute(%qtconsole)?
P.S. If someone know, tell me please how to escape `(backquote) symbol in code-mode.
Reposting as an answer:
If you just run ipython3 in a terminal, what you get is a pure terminal interface, it's not running a kernel that the Qt console can talk to.
If you run ipython3 console, you'll get a similar interface but it will be talking to a kernel, so you can start a Qt console to interact with it. You can either run %qtconsole from inside that interface, or run ipython qtconsole --existing in a shell to start a Qt console and connect to an existing kernel.

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

Enthought Canopy ipython configuration: bad interpreter No such file or directory

I'm trying to launch Enthought Canopy's ipython from a Terminal in Mac OS 10.8.3 using the following command:
/Applications/Canopy.app/appdata/canopy-1.0.0.1160.macosx-x86_64/Canopy.app/Contents/bin/ipython
but I'm receiving the following error:
/Applications/Canopy.app/appdata/canopy-1.0.0.1160.macosx-x86_64/Canopy.app/Contents/bin/ipython: /Library/Frameworks/Python.framework/Versions/7.1/Resources/Python.app/Content: bad interpreter: No such file or directory
This (7.1) framework was previously installed but was removed long ago, so I can't quite figure out where Canopy's IPython is getting this link from. I've checked my ./ipython/profile_default directory as well but this didn't help.
Any idea how I might be able to launch ipython from a Terminal?
Thanks!
Canopy uses virtual environments to setup a user environment which is isolated from the environment in which the app itself is running. This prevents any changes made to the environment, by the user, from crashing the application itself.
To run an IPython terminal, with access to any packages that you may have installed via the package manager, you should run IPython from the User environment -- ~/Library/Enthought/Canopy_64bit/User/bin/ipython