Cannot print Circuit ascii diagram
See original GitHub issueHi,
I created a basic circuit and tried to print it to console. It hit me with the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode characters in position 3-5: ordinal not
in range(128)
My code is as follows:
import cirq
# Build a model using Circuits
circuit = cirq.Circuit()
# Create Qubits
(q0, q1) = cirq.LineQubit.range(2)
# Add Qubits to Circuit model using logic gates
circuit.append([cirq.H(q0), cirq.CNOT(q0, q1)])
# Measure the final values of the Qubits
circuit.append([cirq.measure(q0), cirq.measure(q1)])
# Visualising the Circuit
print (circuit)
Can someone tell me how I can fix this and visualise my circuit? Thanks!
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
ASCII circuit diagrams | Electronics Forums
I've looked at a few of these, posted in this group, and I'm competely unable to understand any of it. Is there some...
Read more >In C++, how to print ASCII art to the console?
command line interface - In C++, how to print ASCII art to the console? - Stack Overflow. Stack Overflow for Teams – Start...
Read more >ASCIIFlow
Infinite ASCII diagrams, save to Google Drive, resize, freeform draw, and export straight to text/html.
Read more >Your Turn: Print ASCII Chart
Open the terminal. Verify that it prints all the printable characters, starting from space (which actually won't visibly display) to ~.
Read more >ASCII-Art : 5 Steps (with Pictures)
1. Choose any image from the internet or from your desktop. It should have no background and not too much little parts. Comic-figures...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is likely a problem with your python environment’s configuration, e.g. the default text encoding is not set to UTF8.
Are you on a windows machine? Are you using python 2 or python 3? If you try
print(circuit.to_text_diagram(use_unicode_characters=False))
does that work as a workaround?That’s why you set global switches in a
if __name__ == "__main__":
block to prevented from changing setting if that file is later imported. But ya, it would be so much easier if standards where… standard.Edit: I’ve updated python from 3.5 to 3.7 and that fixed the problem for me. I heard updating to 3.6 also works but I haven’t checked myself.