eclipse-qrisp / Qrisp

Qrisp - a framework for high-level programming of Quantum computers
https://www.qrisp.eu/
Eclipse Public License 2.0
84 stars 23 forks source link

print(qv.qs) does not work #9

Closed unico20 closed 1 year ago

unico20 commented 1 year ago

Hi all :) I have problems with printing circuits:

from qrisp import QuantumVariable
qv = QuantumVariable(1)
print(qv.qs)

yields

UserWarning: Style JSON file 'text.json' not found in any of these locations: /path/to/qiskit/visualization/styles/text.json, text.json. Will use default style.
  self._style, def_font_ratio = load_style(style)
QuantumCircuit:
---------------
Figure(220.973x451.5)
Live QuantumVariables:
----------------------
QuantumVariable qv_0

Does anyone know the file 'text.json' or have a clue how to get it?

I have python version 3.8.10 installed and the following __qiskit_version__: {'qiskit-terra': '0.24.1', 'qiskit-aer': '0.12.0', 'qiskit-ignis': None, 'qiskit-ibmq-provider': '0.20.2', 'qiskit': '0.43.1', 'qiskit-nature': None, 'qiskit-finance': None, 'qiskit-optimization': None, 'qiskit-machine-learning': None}

Thanks a lot for any inspiration :-)

positr0nium commented 1 year ago

Hi, this seems like a Qiskit related problem. Did you try reinstalling Qiskit or installing a different version? My local version and the GitHub repo don't have the folder "styles"

unico20 commented 1 year ago

Thanks a lot for your help. Yes, I have reinstalled Qiskit and tried with other versions. I also tried with another Python version (3.10.12) and with virtual environments with

In all cases, I obtained a similar error:

/path/to/qiskit/visualization/matplotlib.py:162: UserWarning: Style JSON file 'text.json' not found in any of these locations: /path/to/qiskit/visualization/styles/text.json, text.json. Will use default style.
  self._style, def_font_ratio = load_style(style)
QuantumCircuit:
---------------
Figure(220.569x117.056)
Live QuantumVariables:
----------------------
QuantumVariable qv_0

What changed, however, is the search path, namely the circuit folder between visualization and styles. This new path also exists in the GitHub repo, but doesn't contain the searched file text.json either :(

positr0nium commented 1 year ago

Can you post the full error message including traceback?

unico20 commented 1 year ago

Yes, I edited the message. Does that help?

positr0nium commented 1 year ago

Your folder structure is different from my local folder structure and also from the github page. The "visualization" folder doesn't contain a matplotlib file. The circuit sub folder contains one, but this file also doesn't contains no such user warning. To me, it seems like you installed the newest version of Qiskit to some environment, but try to start Qrisp/Qiskit (unintentionally) in a different environment. This would explain why your folder structure looks different in the error message. Maybe clear your PATH variable?

positr0nium commented 1 year ago

The warning you posted is in this file now

unico20 commented 1 year ago

The whole path is home/unico/anaconda3/envs/Qrisp_env/lib/python3.10/site-packages/qiskit/visualization/matplotlib.py or similar: I used different environments (here: Qrisp_env) to try different versions of python/qiskit.

positr0nium commented 1 year ago

That file, matplotlib.py should not be in that folder. Can you try reinstalling from different sources (make a new environment for this):

If you used Conda for installation, try pip or try Conda if you previously used pip. If it still doesn't work, you can be super sure and install from source. For this follow these steps

  1. Download the Qiskit repo either as a zip or using git
  2. Create a new environment
  3. Open a console with that environment activated
  4. Navigate to the top folder of the Qiskit repo (containing setup.py)
  5. Execute pip install -e ./

More info on installing from source here