6
$\begingroup$

I'm trying to follow the instructions here https://qiskit.org/documentation/getting_started.html. It says

The default backend for qiskit.visualization.circuit_drawer() or QuantumCircuit.draw() is the text backend. However, depending on your local environment you may want to change these defaults to something better suited for your use case. This is done with the user config file. By default the user config file should be located in ~/.qiskit/settings.conf and is a .ini file.

I don't see this config file anywhere. Can anyone tell me how I can find the location of this file in order to make the change from the text based plotter to the nicer plotter?

$\endgroup$
7
$\begingroup$

If you are working in Windows, the default location should be C:\Users\[user]\.qiskit, which might be hidden by default. Create a text file in that folder named settings.conf and set it up how you like.

For example by default

from qiskit import *
qc = QuantumCircuit(2)
qc.h(0)
qc.x(1)
qc.draw()

produces

text drawer circuit output

With settings.conf in the folder referenced above, containing the two lines

[default]
circuit_drawer=mpl

the same code produces

mpl drawer circuit output

$\endgroup$
5
  • $\begingroup$ Thank you very much. And since I will be using this on a Mac as well, can I ask where this file should be in a Mac? $\endgroup$ Nov 6 '19 at 22:42
  • 1
    $\begingroup$ @user1936752 Sorry, I've never worked with qiskit in iOS. However, if you have your API token stored locally, you should have a file named qiskitrc in this folder already. Try doing a search for that file. $\endgroup$ Nov 6 '19 at 22:47
  • 2
    $\begingroup$ @user1936752 Is it not just Users/[user]/.qiskit? If not a search for .qiskit should lead you there as well. $\endgroup$ Nov 6 '19 at 23:41
  • $\begingroup$ Thank you - you were indeed correct. However it may be worth adding to your answer that this folder might be hidden! It was for me, hence the trouble finding it $\endgroup$ Nov 7 '19 at 12:01
  • 1
    $\begingroup$ @user1936752 No problem! It's in there, first sentence. $\endgroup$ Nov 7 '19 at 12:29
4
$\begingroup$

Use the command ls -alt in Terminal on macOS to find hidden files. It's there. This should work for all Mac users.

$\endgroup$
1
$\begingroup$

I am still unable to see the ~/.qiskit/settings.conf file. Did the listing to show hidden files as well as created a new conda environment for a new qiskit environment.

I am on a mac and following the instructions listed here: https://qiskit.org/textbook/ch-prerequisites/setting-the-environment.html

$\endgroup$
2
  • $\begingroup$ Hi and welcome to Quantum Computing SE. When you have enough reputation, please add posts like yours as Comment. $\endgroup$ Nov 28 '20 at 7:35
  • $\begingroup$ Did you first navigate to the directory using the command: cd ~/.qiskit/ and then use the command ls -alt ? Also, how did you install python Conda? I recently ran into an issue of not having PIP installed, which is why I ask how you installed. Make sure pip is installed using: "pip --version". If it's not installed you can do so using "sudo easy_install pip" PIP is just a helpful tool to download python packages. See link: w3schools.com/python/python_pip.asp ... You can use terminal command to search for files..., but there are several files to be search... $\endgroup$
    – Lizzo
    Nov 28 '20 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.