ipython

How to set ipython/jupyter as the default python terminal for vscode?

≯℡__Kan透↙ 提交于 2019-12-12 17:50:51
问题 How can I choose ipython/jupyter as the DEFAULT python terminal? I use both a windows 10 and a linux machine with the anaconda distribution. If I type "ipython" on the terminal, it opens an ipython session. If I run the debugger or shift+enter a line, it automatically runs on a "barebones" python shell. Should be simple...but I have been googling and messing with the settings for half an hour with no success. Looked up https://code.visualstudio.com/docs/python/tutorial-flask Use IPython REPL

Sending code from Python buffer to IPython session running from M-x ansi-term

ぃ、小莉子 提交于 2019-12-12 15:18:26
问题 Say I open a terminal emulator in Emacs with M-x ansi-term . This opens a buffer in Emacs with the shell of my choice. Say I then run ipython from this shell. Can I send code to this ipython session from another buffer with Python code in Emacs? If so how? 回答1: I have a minor mode for this purpose (except it is not IPython-specific and I mostly use it for shell scripts): isend-mode. Here is how you would use it: Open an ansi-term buffer: M-x ansi-term RET /usr/bin/ipython RET Open the buffer

What is the correct way to read sys.stdin in iPython qtconsole

社会主义新天地 提交于 2019-12-12 15:14:12
问题 I'm trying to write a library that will work as well across platforms as standard Python, iPython and within qtConsole. Everything works except my keyboard interaction. I want things like 'press any key' or 'press Y/N/Esc' In Windows this is easy with msvcrt and kbhit. (though I've not tried qtconsole in windows) In Linux this works using stdin and termios under both Python and iPython. The trouble is it seems qtconsole uses non-blocking stdin and does not support termios. You would think

使用jupyter notebook连接服务器进行远程炼丹

不羁岁月 提交于 2019-12-12 14:03:04
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 之前有人分享过使用VSCode远程炼丹 今天分享用jupyter notebook实现同样的功能 (1)简单介绍一下jupyter notebook的优点 Jupyter Notebook是一个开源的Web应用程序,旨在方便开发者创建和共享代码文档。 它提供了一个环境,用户可以在里面 写代码、运行代码、查看结果,并在其中可视化数据 。 直接进入主题 注意:以下操作均在服务器上操作 1)确认是否已经安装jupyter notebook 如未安装,打开终端输入 sudo pip install jupyter (如果后续出现提示缺少其他配置,需根据自身情况进行安装即可) 2)生成配置文件 终端中输入 jupyter notebook --generate-config 生成的配置文件(一般配置文件的位置** ~/.jupyter/jupyter_notebook_config.py** ),后面需要用到。这里请稍安勿躁!可查看确认是否正确生成 注意:如果之前安装过,可能会提示你是否要重置配置文件,推荐不要,例如本机上重置可能会导致jupyter notebook无法正常在浏览器打开(当然也是有办法解决的) 3)生成密码(后续写配置文件、登录Jupyter notebook需要,需要输入一大堆东西) 打开

How to access Globals() of parent module into a sub-module?

谁都会走 提交于 2019-12-12 12:26:55
问题 I have a function in a sub-module which needs to manipulate the variables from parent/interpreter Globals (assertion, validation) like this: import mymodule mymodule.fun_using_main_interpreter_globals1() If I do this, it works: mymodule.fun_using_main_interpreter_globals1(explicit_pass= globals() ) But, If I dont pass explictely globals(), how can I get access to interpreter/parent globals() into my sub-module ? In IPython, it can be put in profile settings. 回答1: I never went for real in this

PyCrypto Possible To Check If File Already AES Encrypted?

自作多情 提交于 2019-12-12 12:12:00
问题 from Crypto.Cipher import AES def encrypt_file(key, in_filename, out_filename=None, chunksize=64*1024): """ Encrypts a file using AES (CBC mode) with the given key. key: The encryption key - a string that must be either 16, 24 or 32 bytes long. Longer keys are more secure. in_filename: Name of the input file out_filename: If None, '<in_filename>.enc' will be used. chunksize: Sets the size of the chunk which the function uses to read and encrypt the file. Larger chunk sizes can be faster for

Best practices when importing in IPython

雨燕双飞 提交于 2019-12-12 12:00:42
问题 I'm writing a .py file which will be regularly imported at the start of some of my IPython sessions in the first cells but will also be imported from other non-interactive sessions, since it contains functions that can be run in batch in non-interactive mode. It is basically a module containing many classes and functions that are very common. Since I'm using IPython with the --pylab=inline option, numpy as well as matplotlib functions are already imported, but when run in batch with a simple

How can I fix “ImportError: no module named shell” error for IPython

左心房为你撑大大i 提交于 2019-12-12 11:05:36
问题 I've seen a number of people recommend that I use the following snippet to embed an IPython shell or drop to an IPython shell from e.g. a django view. from IPython.Shell import IPShellEmbed ipython = IPShellEmbed() ipython() But when I do this, I get >>> from IPython.Shell import IPShellEmbed Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named Shell How can I embed IPython or start an IPython console from an existing python app? 回答1: The

Strange increment value reported during IPython memory profiling

百般思念 提交于 2019-12-12 10:54:36
问题 While checking Jake van der Plas' "Python Data Science Handbook", I was recreating the usage examples of various debugging and profiling tools. He provides an example for demonstrating %mprun with the following function: def sum_of_lists(N): total = 0 for i in range(5): L = [j ^ (j >> i) for j in range(N)] total += sum(L) del L return total I proceeded to execute it in a Jupyter notebook, and got the following output: Line # Mem usage Increment Line Contents ==================================

IPython notebook shows output in terminal

旧时模样 提交于 2019-12-12 10:48:51
问题 I'm using an IPython notebook ( ipython notebook & ), but when I try to print something to get any output by simply giving the variable name ans pressing Shift + Enter, instead of getting the output in notebook (next to the cell), I get it in the terminal from where I launch the notebook. I want to see the output in the notebook itself, next to the concerned cell. I'm facing this problem lately, previously it was working fine. 回答1: This code produces the same issue on my machine: import sys