2

I tried to follow the examples at Quantum Circuit Plotting with SymPy but I could not find the output picture.

My OS is Ubuntu and I typed all the commands in the terminal of IPython, as you can see here:

enter image description here

The output is similar to the one in that website,

<sympy.physics.quantum.circuitplot.CircuitPlot object at 0x7fa125ee5c10>

So, where is the output figure? In some folder?

PS: I run again and get another similar but different output

<sympy.physics.quantum.circuitplot.CircuitPlot at 0x7f6ff0903690>
karel
  • 110,292
  • 102
  • 269
  • 299
Eden Harder
  • 697
  • 1
  • 6
  • 13
  • What command/tool have you used and how did you get that result? What is it supposed to do and what is not doing? – Lucio Sep 07 '14 at 02:51
  • 1
    I never used this software but as I understand this you should not get the pictures that you see on the website on your terminal. That is even impossible to print using chars. It should be data on a variable that should be used with another tool that actual display that data as a graphic. Why do you think you should see the output on the terminal? – Lucio Sep 07 '14 at 03:43
  • He isn't asking why he can't see it in the terminal, he's asking how he gets those images, the plots - what is the author using to create those plots from the outputted data – ElefantPhace Sep 07 '14 at 04:03
  • Isn't the output a QASM file? Then there is a package, qasm2circ, to turn a QASM file to a figure, as explained in the very first link on your linked webpage... btw, this is not an Ubuntu question. – Chan-Ho Suh Sep 07 '14 at 04:27
  • @Chan-HoSuh Thanks! The output is not a QASM file. The author want to use python to do what the latex package qasm2circ can do. – Eden Harder Sep 07 '14 at 04:32
  • You have all the necessary dependencies like matplotlib? In any case, you'd be better off asking in a SymPy forum, not an Ubuntu one. – Chan-Ho Suh Sep 07 '14 at 04:40
  • @Chan-HoSuh Thanks! matplotlib is OK. I will ask in a SymPy forum. – Eden Harder Sep 07 '14 at 05:18

1 Answers1

3

In all currently supported versions of Ubuntu open the terminal and type:

sudo apt install ipython python-sympy python-matplotlib # for Python 2.x in Ubuntu 18.04 and earlier

or

sudo apt install ipython3 python3-sympy python3-matplotlib # for Python 3.x 

Start the IPython interpreter with the --pylab option like this: ipython --pylab to enable showing the output plot as shown in the below screenshot. The Python code in the screenshot is identical to the code in the question.

enter image description here
X gate test

karel
  • 110,292
  • 102
  • 269
  • 299
  • It works! Why we must need ipython notebook? Why would not other editors work? For example, IPython QT console. – Eden Harder Sep 07 '14 at 05:56
  • bounty worthy.. definitely – don.joey Sep 07 '14 at 05:59
  • @karel Thanks! I typed an example in the QT console but there is no figure output. – Eden Harder Sep 07 '14 at 06:14
  • @karel Thanks! Then the key point is that `--pylab` is necessary and will not auto-start? – Eden Harder Sep 07 '14 at 06:57
  • If you try running `CircuitPlot(CNOT(1,0),2)` without the `--pylab` flag, you get only the text output that says something like: ``. At this website: http://packages.ubuntu.com/trusty/amd64/python-matplotlib/filelist you can see that the pylab.py file comes from the python-matplotlib package. – karel Sep 07 '14 at 07:22
  • IPython Notebook is not necessary. The `--pylab` option of `ipython` also works in the terminal. – karel Dec 09 '18 at 12:58