Skip to content

ModuleNotFoundError: No module named 'utils' in amazon braket

0

"When using Amazon Braket, I'm encountering a ModuleNotFoundError: No module named 'utils'. How can I resolve this issue and correctly import the utils module?"

asked 2 years ago616 views

2 Answers
2

The ModuleNotFoundError you're encountering suggests that Python can't find the 'utils' module in your current environment. Since that there isn't a top-level Python package called 'utils', you might want to make sure that 'utils' is a package in your current directory or Python path.

If you are trying to use the draw_pulse_sequence module from the utils directory (https://github.com/amazon-braket/amazon-braket-examples/tree/main/examples/pulse_control/utils) of the braket example repo, you need this utils folder (and it's content) in the same folder as your notebook. The simplest solution is to clone the examples repo with git clone git@github.com:amazon-braket/amazon-braket-examples.git, and create your notebook in the pulse_control (https://github.com/amazon-braket/amazon-braket-examples/tree/main/examples/pulse_control) folder

answered 2 years ago

0

Hello,

are you referencing the module correctly ? Can you post your code please ?

Are you using the latest version of the library ? https://github.com/amazon-braket/amazon-braket-sdk-python/tree/main

EXPERT

answered 2 years ago

  • %matplotlib inline

    from braket.aws import AwsDevice from braket.devices import Devices from braket.parametric import FreeParameter from braket.pulse import PulseSequence from braket.circuits import Circuit, GateCalibrations, QubitSet from braket.circuits.gates import Rx, Rz, CZ from braket.circuits.serialization import IRType

    import math from utils.draw_pulse_sequence import draw import matplotlib.pyplot as plt

    Following is the error:

    ModuleNotFoundError Traceback (most recent call last) Cell In[112], line 12 9 from braket.circuits.serialization import IRType 11 import math ---> 12 from utils.draw_pulse_sequence import draw 13 import matplotlib.pyplot as plt

    ModuleNotFoundError: No module named 'utils'

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.