Quantum Workspace Azure Notebook - cell magic %%qsharp not found

BjornD Jensen 51 Reputation points
2023-12-10T13:28:53.98+00:00

I try to run a quantum notebook in Azure Quantum Workspace.

The note bokk is Python 3.

I would like to run a single cell in Q# mode, e.g. I type "%%qsharp"

But I'm getting:

UsageError: Cell magic %%qsharp not found.

??

shouldn't it be possible to switch between Python and Q# back and forth in same notebook?

BR

Bjorn

Azure Quantum
Azure Quantum
An Azure service that provides quantum computing and optimization solutions.
60 questions
{count} votes

2 answers

Sort by: Most helpful
  1. BjornD Jensen 51 Reputation points
    2023-12-10T14:24:10.4666667+00:00

    I figured it out (-:

    In a cell before matic command is used, one have to do this:

    import qsharp
    
    1 person found this answer helpful.

  2. kobulloc-MSFT 23,496 Reputation points Microsoft Employee
    2023-12-10T20:17:23.3266667+00:00

    Hello, @BjornD Jensen !

    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others (Opens in new window or tab)", I'll repost your solution in case you'd like to "Accept (Opens in new window or tab)" the answer.

    Issue:

    I'm running a quantum Python 3 notebook in Azure Quantum Workspace, but I'm getting a UsageError: Cell magic %%qsharp not found when trying to run a single cell in Q# mode, (e.g. I type "%%qsharp"). Shouldn't it be possible to switch between Python and Q# back and forth in same notebook?

    Solution (by BjornD Jensen):

    I figured it out (-: In a cell before matic command is used, one have to do this:

    import qsharp
    
    0 comments No comments