Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

mybinder notebook integer-factorization does not work #677

Open
wim-van-dam opened this issue Jun 10, 2022 · 3 comments
Open

mybinder notebook integer-factorization does not work #677

wim-van-dam opened this issue Jun 10, 2022 · 3 comments

Comments

@wim-van-dam
Copy link

When trying to run the integer-factorization mybinder notebook, the from Microsoft.Quantum.Samples.IntegerFactorization import FactorSemiprimeInteger in the first cell gives a ModuleNotFoundError: No module named 'Microsoft' error.

To reproduce this error:

  1. Go to: https://aka.ms/try-qsharp
  2. Under Integer factorization, select Q#+ Python to Run in browser; this is the URL: https://hub.gke2.mybinder.org/user/microsoft-quantum-698yo5d6/notebooks/samples/algorithms/integer-factorization/host.py
  3. Execute the first cell.

I'm running this using Edge V102 on Windows 11.

Screenshot is attached.
Screenshot 2022-06-10 100930

@tcNickolas
Copy link
Member

I can reproduce this when running this sample locally as a Python script.

I could fix that by adding the following lines

qsharp.packages.add("Microsoft.Quantum.Numerics::0.25.218240")
qsharp.reload()

right after import iqsharp. It looks like Python cannot discover the Microsoft.Quantum.Numerics NuGet package when building Q# code? I think Ryan added automatic package load on startup back in fall 2020, which removed the need to do qsharp.packages.add manually.

@cgranade @anjbur Were there any recent changes to the way IQ# discovers NuGet packages that could cause this?

@tcNickolas
Copy link
Member

The failure on the first cell should be fixed now with #705.
However, we still won't get a result by running this sample on Binder as is, since host.py assumes it's running from the command line rather than as a Jupyter Notebook, and Binder passes it some arguments that are not recognized, so it throws the following error:

usage: ipykernel_launcher.py [-h] [-n NUMBER] [-t TRIALS] [-u]
ipykernel_launcher.py: error: unrecognized arguments: -f /home/jovyan/.local/share/jupyter/runtime/kernel-8d0b3e96-97eb-4d4e-8cb9-9ed5c0f951fe.json

@cgranade
Copy link
Contributor

Thanks for the report! In general, not all of our CLI-style samples have been converted to notebooks yet; will mark this as an enhancement to track that suggestion.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants