microsoft / iqsharp

Microsoft's IQ# Server.
https://docs.microsoft.com/quantum
MIT License
126 stars 58 forks source link

Python import qsharp error #36

Closed cgranade closed 4 years ago

cgranade commented 5 years ago

This issue was originally filed by @patrickxli as MicrosoftDocs/quantum-docs-pr#473.

When I import qsharp in Python, I see the following error:

import qsharp
Preparing Q# environment...
...................Traceback (most recent call last):

File "", line 1, in
import qsharp

File "D:\Anaconda3\lib\site-packages\qsharp_init_.py", line 119, in
client = _start_client()

File "D:\Anaconda3\lib\site-packages\qsharp\clients_init_.py", line 47, in _start_client
raise Exception("Q# environment was not available in allocated time.")

Exception: Q# environment was not available in allocated time.

How to fix it? Any advice?

Thanks!

cgranade commented 5 years ago

Thanks for filing this issue, @patrickxli! This may be an example of #20, which can cause the IQ# kernel to crash or to take a very long time to load if run directly from your home directory; which directory did you try running from?

ghost commented 4 years ago

Go to the location where the site package qsharp is installed and go to qsharp\clients\ init .py and and change the range in the for loop from 20 to some other value greater than 20. (I chose 100). This requires administrator privileges. i.e. Open IDLE or any other Python interpreter or IDEs in administrator mode.

emzatos commented 4 years ago

I am also running into this issue on a docker image, I am attempting to run 'python host.py' on the chemistry samples, specifically AnalyzeHamiltonian. I'm not sure if I am able to modify the qsharp timeout value from the image, so I don't have a mitigation as of now.

ghost commented 4 years ago

I am also running into this issue on a docker image, I am attempting to run 'python host.py' on the chemistry samples, specifically AnalyzeHamiltonian. I'm not sure if I am able to modify the qsharp timeout value from the image, so I don't have a mitigation as of now.

I am not using Windows Pro or Enterprise to support the installation of Docker. When I tried to install Docker on Windows 10 Home Edition (1909) it popped the error that it needs Windows Pro etc. So, I am not sure of the docker image. The module chemistry.py in the qsharp site package has functions like FermionHamiltonian etc. but not AnalyzeHamiltonian here. If you could show the details of the error being displayed I might help.

rmshaffer commented 4 years ago

Closing this since #49 and #154 now prevent IQ# from recursively searching all subfolders of the current folder, which should address the major issue here.

@emzatos, if you are still running into a similar error, please open a new issue with specific details on your scenario.