ipython

No module named sympy

不想你离开。 提交于 2019-12-12 10:38:48
问题 Hi I'm learning linear algebra with python with an Edx course. (http://nbviewer.ipython.org/github/ULAFF/notebooks/tree/may-14-2014/). On "02.4.2.10 Practice with matrix-vector multiplication" with the first box, the code is: import generate_problems as gp print("What is the result of the matrix vector product below?") p = gp.Problem() p.new_problem() generate_problems is a module that the professor at Edx created. However, I got an error importing sympy. I got the error below: --------------

How to install ipython qtconsole with pyenv (Python version 3.4.2)

你离开我真会死。 提交于 2019-12-12 09:21:11
问题 I am using Ubuntu 14.04. I installed pyenv and then installed Python 3.4.2 under pyenv . Then I switched to version 3.4.2: $ pyenv global 3.4.2 Now I would like to install ipython and the qtconsole : $ pip install ipython $ ipython3 qtconsole & This gives an error message (traceback not shown): ImportError: Could not load requested Qt binding. Please ensure that PyQt4 >= 4.7 or PySide >= 1.0.3 is available, and only one is imported per session. Currently-imported Qt library: Noneu PyQt4

Hide imported modules to interpreter

冷暖自知 提交于 2019-12-12 08:37:14
问题 I have built a module which is using a few different modules for various tasks. When I'm importing my module in IPython and listing the available functions for autocompletion, these external modules are included in that list. Is it possible to hide them in some way? 回答1: In Python, modules can define an __all__ variable, which is a list of the names that should be imported when someone does: from module import * IPython can use the same variable to limit completions, though it does not do

ipython ipdb, when invoked via ipdb.set_trace(), does not remember the command history while debugging

不打扰是莪最后的温柔 提交于 2019-12-12 08:21:38
问题 iPython does remember the command history if I run ipython normally, e.g. to mess around testing basic things in the repl, but I would like to be able to pull up the debugging commands from the previous debug session, and I am doing my debugging by simply running my program as normal, where the program contains import ipdb def info(type, value, info): import traceback traceback.print_exception(type, value, info) ipdb.pm() import sys sys.excepthook = info trace = ipdb.set_trace Which is to set

ctypes in python crashes with memset

戏子无情 提交于 2019-12-12 08:14:08
问题 I am trying to erase password string from memory like it is suggested in here. I wrote that little snippet: import ctypes, sys def zerome(string): location = id(string) + 20 size = sys.getsizeof(string) - 20 #memset = ctypes.cdll.msvcrt.memset # For Linux, use the following. Change the 6 to whatever it is on your computer. print ctypes.string_at(location, size) memset = ctypes.CDLL("libc.so.6").memset memset(location, 0, size) print "Clearing 0x%08x size %i bytes" % (location, size) print

Pandas / IPython Notebook: Include and display an Image in a dataframe

旧巷老猫 提交于 2019-12-12 08:05:50
问题 I have a pandas Dataframe which also has a column with a filename of an image. How can I display the image inside of the DataFrame? I tried the following: import pandas as pd from IPython.display import Image df = pd.DataFrame(['./image01.png', './image02.png'], columns = ['Image']) df['Image'] = Image(df['Image']) But when I show the frame, each column only shows the to_string representation of the Image Object. Image 0 IPython.core.display.Image object 1 IPython.core.display.Image object Is

plus/minus operator for python ±

时光怂恿深爱的人放手 提交于 2019-12-12 07:59:37
问题 I am looking for a way to do a plus/minus operation in python 2 or 3. I do not know the command or operator, and I cannot find a command or operator to do this. Am I missing something? 回答1: Another possibility: uncertainties is a module for doing calculations with error tolerances, ie (2.1 +/- 0.05) + (0.6 +/- 0.05) # => (2.7 +/- 0.1) which would be written as from uncertainties import ufloat ufloat(2.1, 0.05) + ufloat(0.6, 0.05) Edit: I was getting some odd results, and after a bit more

How to make iPython use Python 2 instead of Python 3

Deadly 提交于 2019-12-12 07:49:35
问题 I have both Python 2.7 and 3.5 installed. If I run a script from the command line using python , it uses Python 2.7, but if I launch iPython, it uses Python 3: kurt@kurt-ThinkPad:~$ python -V Python 2.7.12 kurt@kurt-ThinkPad:~$ ipython Python 3.5.2 (default, Sep 10 2016, 08:21:44) Type "copyright", "credits" or "license" for more information. IPython 5.1.0 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's

Syntax Highlighting in iPython Notebook Markdown Cell

六眼飞鱼酱① 提交于 2019-12-12 07:47:13
问题 Is there a way to get a Markdown cell in iPython Notebooks to highlight syntax in code blocks? For instance, in GitHub, one can get the desired effect via the following. ```python >>>print('hello') ``` 回答1: The GitHub Flavored Markdown-style of denoting code using the triple-backtick is now supported in IPython master branch on GitHub, and so will be included in the 1.0 release. As Jakob noted, even prior to this, you could use regular markdown for code, in which you just need to indent your

How to reload modules in django shell?

眉间皱痕 提交于 2019-12-12 07:08:26
问题 I am working with Django and use Django shell all the time. The annoying part is that while the Django server reloads on code changes, the shell does not, so every time I make a change to a method I am testing, I need to quit the shell and restart it, re-import all the modules I need, reinitialize all the variables I need etc. While iPython history saves a lot of typing on this, this is still a pain. Is there a way to make django shell auto-reload, the same way django development server does?