from qsharp import compile on windows python 3.8
Hi qsharp team,
On windows with python 3.8 the import of qsharp fails with the following error message:
from qsharp import compile as qscompile # type: ignore
C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\site-packages\qsharp_init_.py:198: in
The fail occurs on the github ci, if you want to you can take a look on it at:
We tried different qsharp version, for example 0.18.2107.153439 and 0.18.2108.160999. The error occurs in all of them.
https://github.com/CQCL/pytket-extensions/runs/3534918995?check_suite_focus=true
If you need more details, please let me know.
Thanks for raising this, @cqc-melf! I'm not able to reproduce locally, would you be willing to share what commands you used to install the qsharp package? Thank you!
Hi @cgranade, thank you for your fast response! You can find this online in our git repository, it contains two steps:
- install iqsharp in https://github.com/CQCL/pytket-extensions/blob/develop/.github/workflows/build_and_test.yml#L123
- install qsharp as requirement in the setup of pytket-qsharp, see https://github.com/CQCL/pytket-extensions/blob/develop/modules/pytket-qsharp/setup.py#L43
If you need more details, please let me know.
No worries, happy to help! That looks like it should work for installing iqsharp, not sure why I'm getting different behavior than you see in your CI. Let me investigate and get back to you. Thanks for the details!
This is a minimal github workflow script that reproduces the issue:
name: Build and test
on:
push:
branches:
- debug/qsharpwin
env:
IQSHARP_TELEMETRY_OPT_OUT: 1
jobs:
windows:
name: Build and test (Windows)
runs-on: windows-2019
steps:
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dotnet SDK and iqsharp
run: |
Invoke-WebRequest "https://dot.net/v1/dotnet-install.ps1" -outfile "dotnet-install.ps1"
.\dotnet-install.ps1
dotnet tool install -g Microsoft.Quantum.IQSharp
pip install jupyter
dotnet iqsharp install --user
pip install qsharp
python -c "import qsharp"
The error occurs with Python 3.8 or 3.9 but not 3.7.
The error goes away if I update pyzmq with pip install -U pyzmq after installing qsharp. Unfortunately, this then falls foul of #376 and we get unpredictable hangs.
With the latest version of qsharp (0.22.186910), the error is different:
Preparing Q# environment...
Exception ignored in: <function Socket.__del__ at 0x000002C50F701790>
Traceback (most recent call last):
File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\site-packages\zmq\sugar\socket.py", line 67, in __del__
self.close()
File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\site-packages\zmq\_future.py", line 160, in close
self._clear_io_state()
File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\site-packages\zmq\asyncio\__init__.py", line 60, in _clear_io_state
self.io_loop.remove_reader(self._fd)
File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\asyncio\events.py", line 504, in remove_reader
raise NotImplementedError
Still seems related to zmq.
This is with the following github-actions script:
name: Build and test
on:
push:
branches:
- test-qsharp
env:
IQSHARP_TELEMETRY_OPT_OUT: 1
jobs:
windows:
name: Build and test (Windows)
runs-on: windows-2019
steps:
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dotnet SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x'
- name: Install iqsharp
run: |
dotnet tool install -g Microsoft.Quantum.IQSharp
pip install jupyter
dotnet iqsharp install --user
pip install -U qsharp
python -c "import qsharp"
Thanks for your report! I believe this should be fixed with #685, but please feel free to re-open if you encounter a regression. Thank you!