ipython

Executing code in ipython kernel with the KernelClient API

一曲冷凌霜 提交于 2019-12-22 08:17:18
问题 I have an existing ipython kernel, with a communication file 'path/comm_file.json' and I want to execute code in this kernel using the Kernel Client API (actually I'm not picky, any method will do..). I understood that this is the best way to do things from the jupyter documentation. So I write the following code: from jupyter_client import KernelClient client = KernelClient(connection_file='path/comm_file.json') client.execute('a = 10') But the execute method leads to the following error:

How to insert a literal tab instead of auto-completing in Jupyter?

时光毁灭记忆、已成空白 提交于 2019-12-22 08:13:14
问题 It is easy to indent a whole line. Just highlight the whole line and press Tab Go to the start of the line and press Tab Click anywhere in the line and press Ctrl + ] Now the problem is how to insert indent in the middle of the line. And also, how to indent at the end of the line. Example usage scenario: # Hyperparameters LENGTH = 10 # length of foo TEMP = 20 # temperature of bar IV = 99.99 # induction variability of foo bar Concretely, we want: # Hyperparameters LENGTH = 10 # length of foo

How to pass command line arguments in IPython jupyter notebook

白昼怎懂夜的黑 提交于 2019-12-22 08:03:42
问题 I a new to Ipython. Currently i have installed Ipython using Anaconda and writing a code to plot chart using jupyter notebook UI. I want to pass few arguments to my working script with the help of argparse module. below is the code.. import argparse parser = argparse.ArgumentParser(description = 'Process display arguments') parser.add_argument('-t', "--test_name", help="Mandatory test name directory path", type=str) parser.add_argument('-s', "--symbolSet", nargs = '?', help="Optional

Plot an IPython Notebook figure inline with fig.show()?

房东的猫 提交于 2019-12-22 07:37:15
问题 I'm calling the inline mode for IPython Notebook using; %pylab inline And the following code plots a figure immediately at the cell; fig = plt.figure() axes = fig.add_axes([0, 0, 1, 1]) However I would like to create the plot/axes etc. in one cell, and plot later using maybe; fig.show() How do I gain more control of the inline mode? If I don't use %pylab inline, it creates the plot in a seperate window which I don't want (and it usually freezes the window). Versions; Numpy: 1.7.0 Matplotlib:

Custom Interactive Shell with AutoComplete

自闭症网瘾萝莉.ら 提交于 2019-12-22 06:54:27
问题 I have been tasked to create an interactive shell to be embedded in python, such that, when called from the command line it will be dropped into that shell. Can anyone recommend me a library that does this? I would need the ability to create custom words, "actions," so when the user types those words, my program can execute the correct function that I have created. I would also like the ability of auto complete / tab complete on the custom words I created. Example: $ python myapplication.py $

Python 3.x on python(x,y)?

a 夏天 提交于 2019-12-22 05:57:18
问题 I'm in the process of setting up a Matlab like environment so I downloaded the latest version of python(x,y) with all the modules that come with it and downloaded python 3.4.1. Does python(x,y) not run the latest version of python? I noticed because the python(x,y) shell doesn't auto calculate mathematical operations into floats which I read is a difference between python 2.x and 3.x. Do I just have to wait for a new release of (x,y) or am I missing something here? 回答1: You can make Python 2

How to run script in Pyspark and drop into IPython shell when done?

喜欢而已 提交于 2019-12-22 05:53:19
问题 I want to run a spark script and drop into an IPython shell to interactively examine data. Running both: $ IPYTHON=1 pyspark --master local[2] myscript.py and $ IPYTHON=1 spark-submit --master local[2] myscript.py both exit out of IPython once done. This seems really simple, but can't find how to do it anywhere. 回答1: If you launch the iPython shell with: $ IPYTHON=1 pyspark --master local[2] you can do: >>> %run myscript.py and all variables will stay in the workspace. You can also debug step

How to work with interactively-defined classes in IPython.parallel?

不问归期 提交于 2019-12-22 05:46:05
问题 Context In an interactive prototyping development on the notebook connected to a cluster, I would like to define a class that is both available in the client __main__ session and interactively update on the cluster engine nodes to be able to move instances of that class around by passing such instances a argument to a LoadBalanced view. The following demonstrates the typical user session: First setup the parallel clustering environment: >>> from IPython.parallel import Client >>> rc = Client(

How to integrate a Ipython console in a PyQT application

蹲街弑〆低调 提交于 2019-12-22 05:14:51
问题 I am developing PyQt software for my lab. In this software, I am loading different kind of RAW and analyzed data from a mySQL database (usually in arrays). I would like to integrate an Iython console in a Widget, so that I could interact easily with these data. I had some difficulties with Ipython 0.13 to do this. Here is what I already have (The whole code is very long, so I just show the part containing the widget, the Ipython console and the corresponding import line, if you need more,

Error: Must specify a primary resource (JAR or Python or R file) - IPython notebook

风格不统一 提交于 2019-12-22 04:59:17
问题 I try to run Apache Spark in IPython Notebook, follow this insruction (and all advice in comments) - link But when I run IPython Notebook by this command: ipython notebook --profile=pyspark I get this error: Error: Must specify a primary resource (JAR or Python or R file) If i run pyspark in shell, everything OK. That means what I have some trouble with connection Spark and IPython. By the way, this my bash_profile: export SPARK_HOME="$HOME/spark-1.4.0" export PYSPARK_SUBMIT_ARGS='--conf