ipython

Can't instantiate Spark Context in iPython

≯℡__Kan透↙ 提交于 2019-12-25 19:01:03
问题 I'm trying to set up a stand alone instance of spark locally on a mac and use the Python 3 API. To do this I've done the following, 1. I've downloaded and installed Scala and Spark. 2. I've set up the following environment variables, #Scala export SCALA_HOME=$HOME/scala/scala-2.12.4 export PATH=$PATH:$SCALA_HOME/bin #Spark export SPARK_HOME=$HOME/spark/spark-2.2.1-bin-hadoop2.7 export PATH=$PATH:$SPARK_HOME/bin #Jupyter Python export PYSPARK_PYTHON=python3 export PYSPARK_DRIVER_PYTHON

cd command in IPython vs. Spyder

浪子不回头ぞ 提交于 2019-12-25 17:17:11
问题 I know that many of the working directory prompts that work in IPython also work in Spyder as long as they're prefaced by %. For example, pwd and ls work in IPython, but to run the same commands in Spyder they need to be prefaced with a % such as: %pwd and %ls . To change the directory in IPython, I can run the cd command like: cd C:\Users\ ... HOWEVER, this doesn't seem to work in Spyder, even when prefaced with a %. Any suggestions? I know that os.chdir ('C:\\Users\\') works, just trying to

IPython, mutable dict keys, possible insanity

淺唱寂寞╮ 提交于 2019-12-25 08:58:46
问题 Dict-keys should probably be immutable, but that's not actually a requirement. All that's required is that the key can be hashed. What happens if I change the object in such a way that its hash changes after inserting it into my dict? Besides just generally "bad things", I'm getting some extra-unexpected behavior. >>> class Foo(object): def __init__(self, n): self.n = n def __hash__(self): return self.n >>> foo = Foo(1) >>> d = {foo : foo.n} >>> print(d) {<__main__.Foo at 0xdeadbeef: 1} >>> d

Using ion() from pylab causes matplotlib to hang

倖福魔咒の 提交于 2019-12-25 06:55:56
问题 I'm using Enthought's 32 bit python distribution for mac. If I try: $ ipython In [1] from pylab import * In [2] ion() In [3] plot([1,2],[1,2]) The figure is created, but python freezes while trying to plot. Am I doing something wrong or is this a bug? plotting by running in ipython --pylab works fine 回答1: I was using the 'WXAgg' backend and I switched to 'macosx' this seems to fix the problem In [1]: import matplotlib In [2]: matplotlib.get_backend() Out[2]: 'WXAgg' In [3]: matplotlib.use(

Pandas: calculating columns conditioned on the values of 2 other columns

妖精的绣舞 提交于 2019-12-25 06:42:45
问题 I have the following abridged dataframe: {'end': {0: 1995, 1: 1997, 2: 1999, 3: 2001, 4: 2003, 5: 2005, 6: 2007, 7: 2013, 8: 2014, 9: 1995, 10: 2007, 11: 2013, 12: 2014, 13: 1989, 14: 1991, 15: 1993, 16: 1995, 17: 1997, 18: 1999, 19: 2001, 20: 2003, 21: 2005, 22: 2007, 23: 2013, 24: 2014, 25: 1985, 26: 1987, 27: 1989, 28: 1991, 29: 1993}, 'idthomas': {0: 136, 1: 136, 2: 136, 3: 136, 4:136, 5: 136, 6: 136, 7: 136, 8: 136, 9: 172, 10: 172, 11: 172, 12: 172, 13: 174, 14: 174, 15: 174, 16: 174,

Seemingly missing ipython module trying to use jupyter notebook with anaconda

纵然是瞬间 提交于 2019-12-25 04:27:28
问题 When opening a jupyter notebook, I get the following errors. Any idea how to fix this? I'm running on ubuntu 16.04 with Anaconda 2. Tried uninstalling and reinstalling ipython and tried doing that through both pip and conda. Didn't help. [E 13:52:02.191 NotebookApp] Unhandled error in API request Traceback (most recent call last): File "/home/user/anaconda2/lib/python2.7/site-packages/notebook/base/handlers.py", line 457, in wrapper result = yield gen.maybe_future(method(self, *args, **kwargs

How to save an ipython session if i used magic %paste ? (magic %save doesn't work)

自作多情 提交于 2019-12-25 03:37:06
问题 It's seems a fairly simple question but I didn't manage to correctly save my ipython session using magic "%save" If i use the magic "%paste" at any time during the session, saving the session results in this output : get_ipython().magic(u'paste') Of course, I would like the pasted code to be saved instead. Any ideas? 回答1: I can reproduce this with version 3.1.0 of ipython on Ubuntu $ ipython Python 2.7.6 (default, Mar 22 2014, 22:59:56) Type "copyright", "credits" or "license" for more

Executing Python Code in IPython Kernel

偶尔善良 提交于 2019-12-24 23:44:35
问题 I want to duplicate ipython notebook capability in Emacs / Pymacs; and I need some direction for a simple code that can 1) send python / "magics" code to a ipython kernel 2) receive the display output, as a string. I found this comment by minrk, the "ipython kernel" example did not work, it gave "ImportError: No module named zmq.blockingkernelmanager". I had better luck with one his other pointers, finally I landed at ipython-1.1.0/IPython/kernel/inprocess/tests/test_kernel.py, I ripped out a

Replace multiline existing output in python

纵然是瞬间 提交于 2019-12-24 20:43:30
问题 In python 3 , there have been answers about how to replace an existing output with another. These answers suggest the use of end='\r' ad in print('hello', end='\r') This is working ofcourse, but it works only for one line . In the program that I post below, I first output 5 lines which is the representation of a table matrix. The user is asked to type one number (1-3) and then the matrix is printed again with an 'X' in the position that the user indicated. But as you can see, the matrix is

Ipython option not visible in spyder

耗尽温柔 提交于 2019-12-24 20:18:28
问题 I just installed the macports versions of spyder and ipython onto my macbook pro running osx 10.8. There does not seem to be a way to open an ipython console from this version of spyder. That is, there is no mention of ipython in the Interpreters menu, nor in the preferences. Has someone come across this problem and might know how to fix it? Many thanks. Adrian 回答1: ( Spyder dev here ) According to this page the latest stable IPython version in MacPorts is 1.0, which is unsupported by Spyder