PySide application with embedded, non-blocking python shell? - ipython

How do I embed a non-blocking Python shell within a PySide application? It must inherit all active objects and variables. There is a simple widget available for this in wxPython but I cannot find the equivalent widget or approach using Qt/PySide. An example using PyQt4 and IPython no longer works, perhaps because that functionality is now packaged differently within the Jupyter Project. I get the error "ImportError: No module named 'IPython.zmq'". I'm fine with using IPython and Jupyter or not. I'm using Python 3.4.

Related

VS code fails to load librairy from a python virtual env

I have a python virtual env generated by poetry somewhere in $HOME/.cache/pypoetry/virtualenvs/pytorch-exploration-7_nwJ185-py3.8. In this venv, I have torch installed as a library. import statements involving torch work while running my program with poetry run. To properly run the program, poetry needs
#!/usr/bin/env python3.8
Despite that I set VScode to use this interpreter $HOME/.cache/pypoetry/virtualenvs/pytorch-exploration-7_nwJ185-py3.8/bin/python3.8, I am still getting "unresolved import 'torch'" from VScode and I am unable to easily look at torch's objects definitions.
I read several hacks like this one but I'd rather find a way to load the actual libraries of the venv to avoid any version mismatch or side effects. Does VScode have the ability to load libraries from the venv based on the declared interpreter?

How to work with Scala in vagrant box spark installation?

I installed spark using instructions provided at https://courses.edx.org/courses/BerkeleyX/CS100.1x/1T2015/courseware/d1f293d0cb53466dbb5c0cd81f55b45b/920d3370060540c8b21d56f05c64bdda/
This lets me run jupyter ipython notebook which provides a pyspark interface on localhost browser. But I wanted to learn more about Scala.
What could be the best way to run Scala using this vagrant based installation. Is there a way that I can run some sort of IDE with this vagrant config. The best would be if I am able to use some notebook like interface to Scala.
Thanks
You can run Scala from jupyter ipython notebook interface. Select New-Terminal. Then, type this command "spark-shell". Scala API window will open.
I hope that will help you

Running Jython with IPython

Is there a way to configure IPython to use an alternative interpreter like Jython? I'd like to be able to quickly experiment with Jython and the JVM and test libraries that I've written. IPython is awesome for regular CPython testing, and I'm hoping to be able to use it with Jython.

Import error when using a python script that do not occur in ipython

All my install for python were working pretty well since soon. Now, I have a weird issue that generates import errors for some of my Python scripts and when using Ipython those import performs as expected.
This issue does not depend on the working dir (tested this several times with the same result). And I didn't change anything in my .bashrc regarding PYTHONPATHs.
So this might be a noob question, but is there an option in Ipython to display everything Ipython is doing when I run a command, so that I can track which is the package Ipython succesfully imported?
The packages I have trouble with are actually yaml, matplotlib cloud Image. Is it possible that an update from 2.6 to 2.7 is responsible for that? (I work on OSX Lion and most of the packages are installed via macports and updated using the upgrade outdated command).
As I think I can probably fix this myself with the command I asked for, don't bother seeking further for package compatibility or anything if you got the Ipython command that might suits me.
The difference of imports between python and ipython resulted from a cross defined python reference library (when installing most of the python libraries with macports and some without any known ports with other package managers).
Reinstalling the whole python libraries using the process described in http://astrofrog.github.io/macports-python/
corrects the issue and it is preferable to install manually the libraries that don't have any known ports (for instance with a setup build/install process).

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