rigetti / pyquil

A Python library for quantum programming using Quil.
http://docs.rigetti.com
Apache License 2.0
1.39k stars 341 forks source link

ModuleNotFoundError: No module named 'typing_extensions' #1773

Closed DS-Liu closed 1 month ago

DS-Liu commented 1 month ago

Pre-Report Checklist

Issue Description

I have installed the quilc and qvm locally according to the [Rigetti’s guide on installing the Quil SDK locally].

After running quilc and qvm, I ran the code in the user guide. Then I met the error ModuleNotFoundError: No module named 'typing_extensions'.

How to Reproduce

Code Snippet

from pyquil import Program, get_qc
from pyquil.gates import *
from pyquil.quilbase import Declare

p = Program(
    Declare("ro", "BIT", 2),
    H(0),
    CNOT(0, 1),
    MEASURE(0, ("ro", 0)),
    MEASURE(1, ("ro", 1)),
).wrap_in_numshots_loop(10)

# run the program on a QVM
qc = get_qc('9q-square-qvm')
result = qc.run(qc.compile(p)).get_register_map().get("ro")
print(result[0])
print(result[1])

Error Output

Traceback (most recent call last):
  File "C:\Users\dsliu\Documents\Projects\Quantum Machine Learing\pyquil\get_started.py", line 1, in <module>     
    from pyquil import Program, get_qc
  File "C:\Users\dsliu\miniconda3\envs\pyquil\lib\site-packages\pyquil\__init__.py", line 2, in <module>
    from pyquil.quil import Program
  File "C:\Users\dsliu\miniconda3\envs\pyquil\lib\site-packages\pyquil\quil.py", line 46, in <module>
    from pyquil.control_flow_graph import ControlFlowGraph
  File "C:\Users\dsliu\miniconda3\envs\pyquil\lib\site-packages\pyquil\control_flow_graph.py", line 2, in <module>
    from typing_extensions import Self, override
ModuleNotFoundError: No module named 'typing_extensions'

Environment Context

Operating System: Windows 10Pro for Workstations 22H2

Python Version (python -V): 3.10.14

Quilc Version (quilc --version): 1.23.0 [e6c0939]

QVM Version (qvm --version): 1.17.1 [cf3f91f]

Python Environment Details (pip freeze or conda list):

# packages in environment at C:\Users\dsliu\miniconda3\envs\pyquil:
#
# Name                    Version                   Build  Channel
bzip2                     1.0.8                h2bbff1b_6
ca-certificates           2024.3.11            haa95532_0
deprecated                1.2.14                   pypi_0    pypi
lark                      0.11.3                   pypi_0    pypi
libffi                    3.4.4                hd77b12b_1
matplotlib-inline         0.1.7                    pypi_0    pypi
msgpack                   1.0.8                    pypi_0    pypi
numpy                     1.26.4                   pypi_0    pypi
openssl                   3.0.13               h2bbff1b_1
packaging                 23.2                     pypi_0    pypi
pip                       24.0            py310haa95532_0
pyquil                    4.10.1                   pypi_0    pypi
python                    3.10.14              he1021f5_1
python-rapidjson          1.16                     pypi_0    pypi
pyzmq                     26.0.3                   pypi_0    pypi
qcs-sdk-python            0.17.9                   pypi_0    pypi
quil                      0.10.0                   pypi_0    pypi
rpcq                      3.11.0                   pypi_0    pypi
ruamel-yaml               0.18.6                   pypi_0    pypi
ruamel-yaml-clib          0.2.8                    pypi_0    pypi
scipy                     1.13.0                   pypi_0    pypi
setuptools                69.5.1          py310haa95532_0
sqlite                    3.45.3               h2bbff1b_0
tenacity                  8.3.0                    pypi_0    pypi
tk                        8.6.14               h0416ee5_0
traitlets                 5.14.3                   pypi_0    pypi
types-deprecated          1.2.9.20240311           pypi_0    pypi
types-python-dateutil     2.9.0.20240316           pypi_0    pypi
types-retry               0.9.9.4                  pypi_0    pypi
tzdata                    2024a                h04d1e81_0
vc                        14.2                 h21ff451_1
vs2015_runtime            14.27.29016          h5e58377_2
wheel                     0.43.0          py310haa95532_0
wrapt                     1.16.0                   pypi_0    pypi
xz                        5.4.6                h8cc25b3_1
zlib                      1.2.13               h8cc25b3_1
DS-Liu commented 1 month ago

Installing the package typing_extensions solves the problem.

python -m pip install typing_extensions