Quantum Computing Asked by Shadab Hussain on February 28, 2021
I’m trying to deploy a simple Quantum App written using Python on Heroku Server which is also using Microsoft’s Q#, but getting the below error:
AttributeError: module 'qsharp' has no attribute 'clients'
Traceback:
File "/app/.heroku/python/lib/python3.6/site-packages/streamlit/script_runner.py", line 332, in _run_script
exec(code, module.__dict__)
File "/app/qrng_final.py", line 18, in <module>
import qsharp
File "/app/.heroku/python/lib/python3.6/site-packages/qsharp/__init__.py", line 123, in <module>
client = _start_client()
File "/app/.heroku/python/lib/python3.6/site-packages/qsharp/clients/__init__.py", line 31, in _start_client
client = qsharp.clients.iqsharp.IQSharpClient()
Log from the docker image:
ovyan@7ca97f8365fb: /appjovyan@7ca97f8365fb:/app$ ls
Dockerfile Operation.qs README.md qrng_final.py runtime.txt
LICENSE Procfile obj requirements.txt setup.sh
ovyan@7ca97f8365fb: /appjovyan@7ca97f8365fb:/app$ ls $HOME/.local/bin
base58 f2py3 pip3 pybind11-config virtualenv
cygdb f2py3.7 pip3.7 sample virtualenv-clone
cython get_objgraph pipenv streamlit watchmedo
cythonize isympy pipenv-resolver streamlit.cmd
f2py pip plasma_store undill
ovyan@7ca97f8365fb: /appjovyan@7ca97f8365fb:/app$ ls $HOME/.local/binls $HOME/.local/bin $HOME/.local/bin $HOME/.local/binc $HOME/.local/bind $HOME/.local/bin $HOME/.local/bin$HOME/.local/bin
ovyan@7ca97f8365fb: ~/.local/binjovyan@7ca97f8365fb:~/.local/bin$ ls streamlit
streamlit
ovyan@7ca97f8365fb: ~/.local/binjovyan@7ca97f8365fb:~/.local/bin$ ls streamlit/streamltit
ls: cannot access 'streamlit/streamlit': Not a directory
ovyan@7ca97f8365fb: ~/.local/binjovyan@7ca97f8365fb:~/.local/bin$ ls streamlit/streamlit streamlit/streamlit streamlit/streamlitc streamlit/streamlita streamlit/streamlitt streamlit/streamlit
cat: streamlit/streamlit: Not a directory
ovyan@7ca97f8365fb: ~/.local/binjovyan@7ca97f8365fb:~/.local/bin$ cat steeamlit
#!/usr/local/bin/python
# -*- coding: utf-8 -*-
import re
import sys
from streamlit.cli import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script.pyw|.exe)?$', '', sys.argv[0])
sys.exit(main())
ovyan@7ca97f8365fb: ~/.local/binjovyan@7ca97f8365fb:~/.local/bin$ cd ..
ovyan@7ca97f8365fb: ~/.localjovyan@7ca97f8365fb:~/.local$ vfcf f ..cd /app
ovyan@7ca97f8365fb: /appjovyan@7ca97f8365fb:/app$ ls
Dockerfile Operation.qs README.md qrng_final.py runtime.txt
LICENSE Procfile obj requirements.txt setup.sh
ovyan@7ca97f8365fb: /appjovyan@7ca97f8365fb:/app$ $HOME/.local/bin/streamlit run qrng_final.py
2021-02-06 23:56:11.279
Warning: the config option 'server.enableCORS=false' is not compatible with 'server.enableXsrfProtection=true'.
As a result, 'server.enableCORS' is being overridden to 'true'.
More information:
In order to protect against CSRF attacks, we send a cookie with each request.
To do so, we must specify allowable origins, which places a restriction on
cross-origin resource sharing.
If cross origin resource sharing is required, please disable server.enableXsrfProtection.
2021-02-06 23:56:13.041
Warning: the config option 'server.enableCORS=false' is not compatible with 'server.enableXsrfProtection=true'.
As a result, 'server.enableCORS' is being overridden to 'true'.
More information:
In order to protect against CSRF attacks, we send a cookie with each request.
To do so, we must specify allowable origins, which places a restriction on
cross-origin resource sharing.
If cross origin resource sharing is required, please disable server.enableXsrfProtection.
You can now view your Streamlit app in your browser.
Network URL: http://172.17.0.2:8501
External URL: http://106.51.241.244:8501
/home/jovyan/.local/lib/python3.7/site-packages/qiskit/quantum_info/operators/pauli.py:107: DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
z = np.zeros(len(label), dtype=np.bool)
/home/jovyan/.local/lib/python3.7/site-packages/qiskit/quantum_info/operators/pauli.py:108: DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
x = np.zeros(len(label), dtype=np.bool)
/home/jovyan/.local/lib/python3.7/site-packages/qiskit/quantum_info/operators/pauli.py:30: DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
arr = np.asarray(arr).astype(np.bool)
/home/jovyan/.local/lib/python3.7/site-packages/qiskit/quantum_info/operators/pauli.py:30: DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
arr = np.asarray(arr).astype(np.bool)
/home/jovyan/.local/lib/python3.7/site-packages/qiskit/quantum_info/operators/pauli.py:107: DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
z = np.zeros(len(label), dtype=np.bool)
/home/jovyan/.local/lib/python3.7/site-packages/qiskit/quantum_info/operators/pauli.py:108: DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
x = np.zeros(len(label), dtype=np.bool)
/home/jovyan/.local/lib/python3.7/site-packages/qiskit/quantum_info/operators/pauli.py:30: DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
arr = np.asarray(arr).astype(np.bool)
/home/jovyan/.local/lib/python3.7/site-packages/qiskit/quantum_info/operators/pauli.py:30: DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
arr = np.asarray(arr).astype(np.bool)
/home/jovyan/.local/lib/python3.7/site-packages/qiskit/quantum_info/operators/pauli.py:107: DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
z = np.zeros(len(label), dtype=np.bool)
/home/jovyan/.local/lib/python3.7/site-packages/qiskit/quantum_info/operators/pauli.py:108: DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
x = np.zeros(len(label), dtype=np.bool)
/home/jovyan/.local/lib/python3.7/site-packages/qiskit/quantum_info/operators/pauli.py:30: DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
arr = np.asarray(arr).astype(np.bool)
/home/jovyan/.local/lib/python3.7/site-packages/qiskit/quantum_info/operators/pauli.py:30: DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
arr = np.asarray(arr).astype(np.bool)
/home/jovyan/.local/lib/python3.7/site-packages/qiskit/quantum_info/operators/pauli.py:107: DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
z = np.zeros(len(label), dtype=np.bool)
/home/jovyan/.local/lib/python3.7/site-packages/qiskit/quantum_info/operators/pauli.py:108: DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
x = np.zeros(len(label), dtype=np.bool)
/home/jovyan/.local/lib/python3.7/site-packages/qiskit/quantum_info/operators/pauli.py:30: DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
arr = np.asarray(arr).astype(np.bool)
/home/jovyan/.local/lib/python3.7/site-packages/qiskit/quantum_info/operators/pauli.py:30: DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
arr = np.asarray(arr).astype(np.bool)
2021-02-06 23:56:17.792 Starting IQ# kernel...
2021-02-06 23:56:23.896 Exception while checking if IQ# is ready.
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/qsharp/clients/iqsharp.py", line 97, in is_ready
result = self.component_versions(timeout=6)
File "/usr/local/lib/python3.7/site-packages/qsharp/clients/iqsharp.py", line 193, in component_versions
self._execute("%version", output_hook=capture, _quiet_=True, **kwargs)
File "/usr/local/lib/python3.7/site-packages/qsharp/clients/iqsharp.py", line 270, in _execute
reply = self.kernel_client.execute_interactive(input, output_hook=_output_hook, **kwargs)
File "/usr/local/lib/python3.7/site-packages/jupyter_client/blocking/client.py", line 321, in execute_interactive
raise TimeoutError("Timeout waiting for output")
TimeoutError: Timeout waiting for output
Preparing Q# environment...
2021-02-06 23:56:27.619 Q# version
{'iqsharp': LooseVersion ('0.15.2101126940'), 'Jupyter Core': LooseVersion ('1.5.0.0'), '.NET Runtime': LooseVersion ('.NETCoreApp,Version=v3.1')}
I have already given Q#package name in requirements.txt
but still not able to resolve it. Is there any solution around how can I install Q# binded with Python on any remote server?
I believe that Heroku does not currently support installing additional software, such as the IQ# kernel used by the qsharp
Python package. That said, Heroku's documentation suggests that using Docker can allow for providing additional dependencies. The Quantum Development Kit is published along with a Docker image, iqsharp-base
, that provides everything you need to use Q# and Python together within a Docker environment:
FROM mcr.microsoft.com/quantum/iqsharp-base:0.15.2101125897
Answered by Chris Granade on February 28, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP