0
$\begingroup$

I'm currently following the "Introduction To Quantum Programming" course of qiskit.

At the beginning of "Visualizing entanglement" chapter : https://learn.qiskit.org/course/introduction/visualizing-entanglement

We have to run this line: from hello_qiskit import run_puzzle

This raises this error :

ModuleNotFoundError: No module named 'hello_qiskit'

I cannot find the hello_qiskit module in my anaconda environnement And if I try to install it with

pip install hello_qiskit I have this error:

ERROR: Could not find a version that satisfies the requirement hello_qiskit (from versions: none) ERROR: No matching distribution found for hello_qiskit

How can I install this module or is there another way to use the run_puzzle function ?

$\endgroup$
4
  • $\begingroup$ Hello, could you put the link to the course you're talking about please? $\endgroup$
    – Lena
    Commented Mar 3, 2022 at 16:16
  • 1
    $\begingroup$ Hello, i just add it, thank you $\endgroup$
    – fyasla
    Commented Mar 3, 2022 at 16:19
  • $\begingroup$ Did you follow the instructions to set up the environment? learn.qiskit.org/course/ch-prerequisites/… $\endgroup$
    – Lena
    Commented Mar 3, 2022 at 16:24
  • $\begingroup$ Yes I did, and everything I followed in the course until this stage worked perfectly $\endgroup$
    – fyasla
    Commented Mar 3, 2022 at 17:14

1 Answer 1

2
$\begingroup$

hello_qiskit is just a python file that lives in the Qiskit Textbook Jupyter Notebook system that is used as a short-cut/helper to interact with qiskit_textbook.games.hello_quantum. In Visualizing Entanglement, if you add

import hello_qiskit
help(hello_qiskit)

to the first cell, you will find a file /home/jovyan/hello_qiskit.py that contains the run_puzzle method, defined as follows:

from qiskit_textbook.games import hello_quantum

def run_puzzle(j):
    puzzle = hello_quantum.run_game(exercises[j]['initialize'],
                           exercises[j]['success_condition'],
                           exercises[j]['allowed_gates'],
                           exercises[j]['vi'],
                           qubit_names=exercises[j]['qubit_names'],
                           mode=exercises[j]['mode']
                          )
    return puzzle

This method references a list exercises of dictionaries defining arguments that will be passed to the run_game method. When you pass an int to the run_puzzle method, you are simply indexing the exercises list defined in hello_qiskit.py. For example, run_puzzle(0) accesses exercises[0], which is defined as

{
    'initialize': [],
    'success_condition': {},
    'allowed_gates': {'0': {'x': 3}, '1': {}, 'both': {}},
    'vi': [[1], True, False],
    'mode': 'line',
    'qubit_names': {'0':'q[0]', '1':'q[1]'}
}

To see how the run_game method is used, see Hello Qiskit Game.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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