I am trying to use the HalfMoon Classifier in Quantum Machine Learning Sample Examples. I am trying to run it locally. However I keep getting this error.

No namespace with the name "Microsoft.Quantum.MachineLearning" exists.

This error is then followed by multiple errors of the identifiers under this namespace not existing. In my python Host.py file

I have the following Import Lines

import qsharp


Replacing Package Version and Making it same as dotnet iqsharp --version did work. However I still seem to getting fail: warnings saying identifiers don't exist and

No namespace with the name "Microsoft.Quantum.MachineLearning" exists.

The program runs correctly but the warnings don't go away. Hence I ask is there anyway to fix these warnings?

  • $\begingroup$ What version of the IQ# kernel do you have installed? (Run dotnet iqsharp --version to see.) Make sure the version of the package you specify in your code matches this. $\endgroup$ Jun 13, 2020 at 11:20
  • $\begingroup$ @RyanShaffer I tried this but it didn't work $\endgroup$
    – vasjain
    Jun 13, 2020 at 11:28
  • $\begingroup$ Are you running the sample as is, without any modifications? Does it build and run if you run it from command line using "dotnet run"? $\endgroup$ Jun 13, 2020 at 18:14
  • $\begingroup$ Thanks for your question! If I could get some additional diagnostic info, that would really help figure out what went wrong. When you ran qsharp.reload(), did that print any error messages to the console? What's the output of qsharp.component_versions()? If you could also try running the same snippet, but with the IQSHARP_LOG_LEVEL environment variable set to Debug, that would really help as well. Thanks! $\endgroup$ Jun 13, 2020 at 18:30
  • $\begingroup$ I apologize to @RyanShaffer. His fix actually did work. However apparently, q# first goes into a preparing q# environment. Resulting in repeated errors about lack of identifiers from the Microsoft.Quantum.MachineLearning Namespace. However later when I simulate the model training and validation. They run correctly. I will edit the question to ask how to get rid of the fail: statement. $\endgroup$
    – vasjain
    Jun 14, 2020 at 10:18


Your Answer

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

Browse other questions tagged or ask your own question.