ipython-magic

Copy to clipboard from IPython using Windows 7

倾然丶 夕夏残阳落幕 提交于 2019-12-05 22:43:06
问题 I am running IPython on Windows 7 and can use the %paste magic command to paste from the clipboard. However, I cannot copy from IPython to the clipboard. I want to copy code snippets from IPython and paste them back to a text editor. Anyone know a fix for this? 回答1: As mentioned by @AdrianRatnapala, you can right-click in the terminal window and select Mark , mark the code snippets you want to copy, and then right-click (the marked content is copied to the clipboard when you right-click). A

Error: Line magic function

假如想象 提交于 2019-12-05 19:58:46
问题 I'm trying to read a file using python and I keep getting this error ERROR: Line magic function `%user_vars` not found. My code is very basic just names = read_csv('Combined data.csv') names.head() I get this for anytime I try to read or open a file. I tried using this thread for help. ERROR: Line magic function `%matplotlib` not found I'm using enthought canopy and I have IPython version 2.4.1. I made sure to update using the IPython installation page for help. I'm not sure what's wrong

Copy to clipboard from IPython using Windows 7

大兔子大兔子 提交于 2019-12-04 04:13:12
I am running IPython on Windows 7 and can use the %paste magic command to paste from the clipboard. However, I cannot copy from IPython to the clipboard. I want to copy code snippets from IPython and paste them back to a text editor. Anyone know a fix for this? As mentioned by @AdrianRatnapala, you can right-click in the terminal window and select Mark , mark the code snippets you want to copy, and then right-click (the marked content is copied to the clipboard when you right-click). A more "permanent way" to use this feature is to right-click on the title bar of the terminal window and choose

Error: Line magic function

房东的猫 提交于 2019-12-04 03:16:52
I'm trying to read a file using python and I keep getting this error ERROR: Line magic function `%user_vars` not found. My code is very basic just names = read_csv('Combined data.csv') names.head() I get this for anytime I try to read or open a file. I tried using this thread for help. ERROR: Line magic function `%matplotlib` not found I'm using enthought canopy and I have IPython version 2.4.1. I made sure to update using the IPython installation page for help. I'm not sure what's wrong because it should be very simple to open/read files. I even get this error for opening text files. EDIT: I

How to run IPython script from the command line - syntax error with magic functions, %

折月煮酒 提交于 2019-12-03 07:11:32
I want to run IPython from the command line. However, I get a syntax error on the first line, importing pylab with the magic function %pylab is giving a syntax error on the %. The command I am using is simply ipython -i script.py . Any ideas how to solve this? You need to name your file script.ipy. When it ends in .ipy it can contain ipython syntax. From ipython --help : Usage ipython [subcommand] [options] [files] If invoked with no options, it executes all the files listed in sequence and exits, use -i to enter interactive mode after running the files. Files ending in .py will be treated as

Can I access python variables within a `%%bash` or `%%script` ipython notebook cell?

走远了吗. 提交于 2019-12-03 01:18:14
问题 Is there a way to access variables in the current python kernel from within a %%bash or other %%script cell? Perhaps as command line arguments or environment variable(s)? 回答1: Python variables can be accessed in the first line of a %%bash or %%script cell, and so can be passed as command line parameters to the script. For example, with bash you can do this: %%bash -s "$myPythonVar" "$myOtherVar" echo "This bash script knows about $1 and $2" The -s command line option allows you to pass

Can I access python variables within a `%%bash` or `%%script` ipython notebook cell?

≯℡__Kan透↙ 提交于 2019-12-02 14:36:44
Is there a way to access variables in the current python kernel from within a %%bash or other %%script cell? Perhaps as command line arguments or environment variable(s)? Python variables can be accessed in the first line of a %%bash or %%script cell, and so can be passed as command line parameters to the script. For example, with bash you can do this: %%bash -s "$myPythonVar" "$myOtherVar" echo "This bash script knows about $1 and $2" The -s command line option allows you to pass positional parameters to bash, accessed through $n for the n-th positional parameter. Note that what's actually

Capture the result of an IPython magic function

吃可爱长大的小学妹 提交于 2019-12-01 15:17:51
问题 I'm trying to capture the resulting object of IPython Notebook magic function. Specifically %timeit So the following code... import time def say_hello(n): time.sleep(n) print "hello" t = %timeit say_hello(5) Prints to stdout: 1 loops, best of 3: 5 s per loop However, I'd like to capture the result of %timeit say_hello(5) in the variable t . A resulting object called TimeitResult is generated by %timeit , but I can't figure out how to access it from within a Notebook. I'd like a cleaner

How do I define custom magics in jupyter?

妖精的绣舞 提交于 2019-12-01 11:29:05
I'm using Ubuntu 14.04 LTS with an Anaconda python installation: Python 3.5.1 :: Anaconda 2.4.1 (64-bit) I'm trying to use this recipe to enable C++ interactive compiling in my ipython notebooks: import IPython.core.magic as ipym @ipym.magics_class class CppMagics(ipym.Magics): @ipym.cell_magic def cpp(self, line, cell=None): """Compile, execute C++ code, and return the standard output.""" # Define the source and executable filenames. source_filename = 'temp.cpp' program_filename = 'temp.exe' # Write the code contained in the cell to the C++ file. with open(source_filename, 'w') as f: f.write

Installing pymatbridge on Windows

怎甘沉沦 提交于 2019-12-01 07:21:35
问题 In version 0.3 of pymatbridge, an additional dependency was added for ZMQ. To install this version, you might therefore need to compile a messenger mex extension linking against a dll of zeromq. However, this turns out to be rather difficult to do in some cases. Does anyone have examples of success stories installing pymatbridge from source on a machine running Windows? 回答1: Some of the other answers are a little bit outdated, and this can be done much more easily now (still won't be as easy