from ... import ... behavior doesn't work for Q# libraries
See original GitHub issueDescribe the bug The following code:
import qsharp
qsharp.packages.add("Microsoft.Quantum.Chemistry")
qsharp.reload()
from Microsoft.Quantum.Chemistry.JordanWigner.VQE import EstimateEnergy
throws this error:
ModuleNotFoundError: No module named 'Microsoft'
Expected behavior
I would expect to be able to use from ... import ...
with libraries.
System information
Running in iqsharp
-based Docker container.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Can I import a local module with the same name as ...
In Python 2.x, you can gain the ability to disambiguate between your local queue and the standard-library one by adding the following line ......
Read more >How to import circuit libraries into qiskit
The way you imported the packages, including the QFT circuit is correct. You just didn't execute it correctly.
Read more >Python import: Advanced Techniques and Tips
This tutorial will provide a thorough overview of Python's import statement and how it works. The import system is powerful, and you'll learn...
Read more >pykx.q Library Reference Card
This library can be installed by calling a helper function within PyKX , this function will move all the required files and libraries...
Read more >'module' is not Accessed Pylance(Pylance is greyed out)
When I am importing the python module 'requests'. PyLance or VSCode underlines it with yellow meaning warning. It is also shown in the ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes indeed that’s what I was thinking, apologies for not being more clear. I like the approach you suggest as well especially because it’s much simpler. In line with your suggestion, instead of saving to a temp location we can indeed just compile directly. On top of that I was thinking to have a convenience function
import_qsharp_operation
or simplyimport_operation
that abstracts away the part where you compile the Q# code:where
For the second use case of generating the boilerplate code, as per your suggestion I agree this could be a nice starting point if people want to tinker with the generated Q# code. If I understood correctly, are you suggesting something like this?
@guenp Thanks for the ping on this. So, this won’t directly solve the problem, but there is already code in IQ# for auto-generating Q# wrappers around an arbitrary Q# operation, which is similar to what you are proposing, I believe: https://github.com/microsoft/iqsharp/blob/249490833c5d4c0728c911eab796b7b22394ffd6/src/Core/Compiler/CompilerService.cs#L148-L168
We could consider exposing some functionality similar to that via Python. Do you have any thoughts on what a convenient way to consume this might look like?