ipython-notebook

matplotlib and libpng issues with ipython notebook

痴心易碎 提交于 2019-11-29 06:34:05
I was trying to use ipython notebook . I installed all the dependency libraries. However, I cannot use either the "--pylab=inline" option when launching ipython or "savefig" function in the Ipython console. When I tried to do either of them, an error message was returned "RuntimeError: Could not create write struct" resulting from execution of matplotlib. Also, a warning from the notebookApp prompt said "libpng warning: Application built with libpng-1.2.41 but running with 1.5.13". However, I installed the newest libpng(1.5.13), uninstalled matplotlib with pip uninstall and reinstalled

How to make Ipython output a list without line breaks after elements?

梦想的初衷 提交于 2019-11-29 05:31:16
The IPython console prints a list of elements with line breaks so that each element is displayed in its own line. This is usually a feature, but in my case it is a bug: I need to copy and paste long lists, so I need a compact representation. How can I achieve this? You can use %pprint command to turn on/off pprint feature: In [1]: range(24) Out[1]: [0, 1, 2, ... 21, 22, 23] In [2]: %pprint Pretty printing has been turned OFF In [3]: range(24) Out[3]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23] If you want to turn off pprint permanently, make a profile

How to check that pylab backend of matplotlib runs inline?

不羁岁月 提交于 2019-11-29 03:02:41
问题 I am modifying a python module that plots some special graphs using matplotlib. Right now, this module just saves all figures as files. I would like to make it possible to import the module while working in ipython notebook and see the results "inline", on the other hand I would like to keep the default functionality of saving the figures as files when the module is imported in all other cases. So I need somehow to check if the module is imported in ipython notebook and the pylab is operating

Draw graph in NetworkX

血红的双手。 提交于 2019-11-29 02:59:06
I'm trying to draw any graph in NetworkX, but get nothing, not even errors: import networkx as nx import matplotlib.pyplot as plt g1=nx.petersen_graph() nx.draw(g1) Add to the end: plt.show() import networkx as nx import matplotlib.pyplot as plt g1 = nx.petersen_graph() nx.draw(g1) plt.show() When run from an interactive shell where plt.ion() has been called, the plt.show() is not needed. This is probably why it is omitted in a lot of examples. If you run these commands from a script (where plt.ion() has not been called), the plt.show() is needed. plt.ion() is okay for interactive sessions,

Can a Jupyter / IPython notebook take arguments in the URL?

时光总嘲笑我的痴心妄想 提交于 2019-11-29 02:52:16
问题 Is it possible to write an Jupyter notebook such that parameters can be passed in via the URL of the notebook? Example, for a URL such as this: http://jupyter.example.com/user/me/notebooks/notebook1.ipynb?Variable1=Value1&Variable2=Value2 how could access Variable1 and Variable2 inside the Jupyter cell? 回答1: You need to find out the URL using JavaScript and pass it to the IPython kernel: from IPython.display import HTML HTML(''' <script type="text/javascript"> IPython.notebook.kernel.execute(

Dynamically changing dropdowns in IPython notebook widgets and Spyre

試著忘記壹切 提交于 2019-11-29 02:47:10
问题 I have a dropdown in an IPython notebook (as part of the HTML widgets) and in a Spyre app (as a dropdown element), say to pick a continent and I'd like to add a second dropdown to select the country within the continent. Now obviously the options within the second dropdown are dependent on the value of the first one. I'm struggling to find a convenient way to have a callback function that would update this UI element. I have almost done this in the IPython notebook where I had one interact

Unable to run unittest's main function in ipython/jupyter notebook

寵の児 提交于 2019-11-29 02:45:31
问题 I am giving an example which throws an error in ipython/jupyter notebook, but runs fine as an individual script. import unittest class Samples(unittest.TestCase): def testToPow(self): pow3 = 3**3 assert pow3==27 if __name__ == '__main__': unittest.main() The error is below: --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-7-232db94ae8b2> in <module>() 8 9 if __name__ == '__main__': ---> 10 unittest.main

How do (can) I use a custom.js file under Jupyter notebook?

走远了吗. 提交于 2019-11-29 02:35:42
问题 In the IPython notebook (v3.1, for example), I could add a ~/.ipython/profile_default/static/custom/custom.js file to execute some custom JavaScript. For example, I could do something like this: require(['base/js/namespace', 'base/js/events'], function(IPython, events) { console.log("A"); events.on('app_initialized.NotebookApp', function() { console.log("B"); }); console.log("C"); }); Then, in the JS console, I would see A , followed by B , followed by C . Now, as of version 4.0, they've

Is it possible to host nbviewer locally?

女生的网名这么多〃 提交于 2019-11-29 02:24:41
I want to bring nbviewer to my job. Because I am not able to share company data (place it on github), I will need to install nbviewer locally. There are instructions to set one up on Heroku but this will not work for me. Has anyone attempted this? Is it even worth the effort? Any other alternatives? Thanks. Steps to get nbviewer running on your local machine: Step1: Download nbviewer from github Step2: Download nbconvert from github Step3: Place nbconvert contents into the "nbconvert" folder inside nbviewer Step4: Get required libraries easy_install Flask==0.9 easy_install Flask-Markdown easy

IPython Notebook run all cells on open

独自空忆成欢 提交于 2019-11-29 02:11:12
I have an IPython noteboook and I'm trying to set it up in a way so that all cells are ran automatically when the notebook is opened. This behaviour is different from saved output for notebooks which contain widgets. Widgets only seem to get rendered for me when the cells containing them are run. Consider the following example: from IPython.display import display from IPython.html.widgets import IntSlider w = IntSlider() display(w) The slider is not displayed until the cell is executed. Is this something that can be accomplished through Notebook Metadata or configuration files? EDIT: https:/