4
$\begingroup$

I'm trying to add the Q# machine learning library to my program by

import qsharp
qsharp.packages.add("Microsoft.Quantum.MachineLearning::0.11.2004.2825")
qsharp.reload()

but it throws the errors below. Any solutions?

P.S. I have the qsharp package and iqsharp installed. Normal programs in python that use qsharp work correctly.

dotnet iqsharp --version
iqsharp: 0.11.2006.403
Jupyter Core: 1.3.60623.0
.NET Runtime: .NETCoreApp,Version=v3.1

and

'iqsharp': LooseVersion ('0.11.2006.403'),
 'Jupyter Core': LooseVersion ('1.3.60623.0'),
 '.NET Runtime': LooseVersion ('.NETCoreApp,Version=v3.1'),
 'qsharp': LooseVersion ('0.11.2006.403')

Also even if I don't add the Machine Learning library and just run

import qsharp
qsharp.reload()

It still throws the same error

Errors:

Adding package Microsoft.Quantum.MachineLearning::0.11.2004.2825.
---------------------------------------------------------------------------
IQSharpError                              Traceback (most recent call last)
<ipython-input-15-b3244a777be2> in <module>
      1 import qsharp
      2 qsharp.packages.add("Microsoft.Quantum.MachineLearning::0.11.2004.2825")
----> 3 qsharp.reload()

~\anaconda3\lib\site-packages\qsharp\__init__.py in reload()
     70     Q# compilation errors are raised as an exception.
     71     """
---> 72     client.reload()
     73 
     74 def get_available_operations() -> List[str]:

~\anaconda3\lib\site-packages\qsharp\clients\iqsharp.py in reload(self)
    117 
    118     def reload(self) -> None:
--> 119         return self._execute(f"%workspace reload", raise_on_stderr=True)
    120 
    121     def add_package(self, name : str) -> None:

~\anaconda3\lib\site-packages\qsharp\clients\iqsharp.py in _execute(self, input, return_full_result, raise_on_stderr, output_hook, **kwargs)
    207         # There should be either zero or one execute_result messages.
    208         if errors:
--> 209             raise IQSharpError(errors)
    210         if results:
    211             assert len(results) == 1

IQSharpError: The Q# kernel raised the following errors:
    C:/Users/Shreyas/Documents/jupyter/Quantum/MLADS2020-QuantumClassification-master/MLADS2020-QuantumClassification-master/test/Operation.qs(2,10): error QS6104: No namespace with the name "Microsoft.Quantum.Convert" exists.
    C:/Users/Shreyas/Documents/jupyter/Quantum/MLADS2020-QuantumClassification-master/MLADS2020-QuantumClassification-master/test/Operation.qs(3,10): error QS6104: No namespace with the name "Microsoft.Quantum.Intrinsic" exists.
    C:/Users/Shreyas/Documents/jupyter/Quantum/MLADS2020-QuantumClassification-master/MLADS2020-QuantumClassification-master/test/Operation.qs(60,21): error QS5022: No identifier with the name "Default" exists.
    C:/Users/Shreyas/Documents/jupyter/Quantum/MLADS2020-QuantumClassification-master/MLADS2020-QuantumClassification-master/test/Operation.qs(61,16): error QS5022: No identifier with the name "Structure" exists.
    C:/Users/Shreyas/Documents/jupyter/Quantum/MLADS2020-QuantumClassification-master/MLADS2020-QuantumClassification-master/test/Operation.qs(62,16): error QS5022: No identifier with the name "Parameters" exists.
    C:/Users/Shreyas/Documents/jupyter/Quantum/MLADS2020-QuantumClassification-master/MLADS2020-QuantumClassification-master/test/Operation.qs(63,16): error QS5022: No identifier with the name "Bias" exists.
    C:/Users/Shreyas/Documents/jupyter/Quantum/MLADS2020-QuantumClassification-master/MLADS2020-QuantumClassification-master/test/Operation.qs(11,16): error QS5022: No identifier with the name "Length" exists.
    C:/Users/Shreyas/Documents/jupyter/Quantum/MLADS2020-QuantumClassification-master/MLADS2020-QuantumClassification-master/test/Operation.qs(30,23): error QS5022: No identifier with the name "Mapped" exists.
    C:/Users/Shreyas/Documents/jupyter/Quantum/MLADS2020-QuantumClassification-master/MLADS2020-QuantumClassification-master/test/Operation.qs(32,13): error QS5022: No identifier with the name "Zip" exists.
    C:/Users/Shreyas/Documents/jupyter/Quantum/MLADS2020-QuantumClassification-master/MLADS2020-QuantumClassification-master/test/Operation.qs(35,13): error QS5022: No identifier with the name "Mapped" exists.
    C:/Users/Shreyas/Documents/jupyter/Quantum/MLADS2020-QuantumClassification-master/MLADS2020-QuantumClassification-master/test/Operation.qs(46,9): error QS5022: No identifier with the name "Message" exists.
$\endgroup$
  • $\begingroup$ Can you share the output of dotnet iqsharp --version at the command line, or qsharp.component_versions() from within Python? That would help us to diagnose your error much better. Thank you for your help! $\endgroup$ – Chris Granade Jun 13 at 20:46
  • $\begingroup$ @ChrisGranade Please check the edited post... I added the versions. Thanks in advance for your help. $\endgroup$ – Shreyas Pradhan Jun 13 at 20:56
  • 3
    $\begingroup$ That helps a lot, thank you! It looks like your IQ# version is 0.11.2006.403, but you're trying to add version 0.11.2004.2825 of the Microsoft.Quantum.MachineLearning package. I'd suggest either downgrading IQ# to 0.11.2004.2825, or modifying the qsharp.packages.add call to use 0.11.2006.403. $\endgroup$ – Chris Granade Jun 13 at 21:02
  • $\begingroup$ Thanks a lot @ChrisGranade! That solved my problem. $\endgroup$ – Shreyas Pradhan Jun 13 at 23:24
  • $\begingroup$ No worries, happy to help! $\endgroup$ – Chris Granade Jun 14 at 3:11
0
$\begingroup$

@ChrisGranade solved my problem:

It looks like your IQ# version is 0.11.2006.403, but you're trying to add version 0.11.2004.2825 of the Microsoft.Quantum.MachineLearning package. I'd suggest either downgrading IQ# to 0.11.2004.2825, or modifying the qsharp.packages.add call to use 0.11.2006.403

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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