-
Notifications
You must be signed in to change notification settings - Fork 982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ugly exception warning when only cirq-core is installed #4106
Labels
area/imports
area/install
area/packages
kind/bug-report
Something doesn't seem to work.
triage/accepted
there is consensus amongst maintainers that this is a real bug or a reasonable feature to add
Comments
95-martin-orion
added
area/imports
area/install
area/packages
triage/accepted
there is consensus amongst maintainers that this is a real bug or a reasonable feature to add
labels
Jun 1, 2021
This is now a problem with aqt and ionq |
Ideas:
try:
deprecated_submodule(cirq_google)
except ImportError:
sys.modules['cirq.google'] = ValueError("Not installed") |
|
CirqBot
pushed a commit
that referenced
this issue
Jul 15, 2021
Adds better error messaging when deprecated module can't be imported. Now, `import cirq` prints zero warnings, even if there are errors importing the modules. Instead, when the deprecated modules are used, an informative error is thrown, including the root cause error: When `cirq_pasqal` can't be imported, `import cirq.pasqal` results in: ``` Traceback (most recent call last): File "/Users/balintp/dev/proj/Cirq/cirq-core/cirq/_compat.py", line 590, in deprecated_submodule new_module = importlib.import_module(new_module_name) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked ModuleNotFoundError: No module named 'cirq_pasqal' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "<string>", line 1, in <module> File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 971, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 914, in _find_spec File "/Users/balintp/dev/proj/Cirq/cirq-core/cirq/_compat.py", line 504, in find_spec raise self.broken_module_exception cirq._compat.DeprecatedModuleImportError: cirq_pasqal cannot be imported. The typical reasons are that 1.) cirq_pasqal is not installed, or 2.) when developing Cirq, you don't have your PYTHONPATH setup. In this case run `source dev_tools/pypath`. You can check the detailed exception above for more details or run `import cirq_pasqal to reproduce the issue. ``` Note that `from cirq import pasqal` will still run and return a dummy module that will throw the same error when trying to access any of its attributes. Fixes #4106. Fixes #4291.
rht
pushed a commit
to rht/Cirq
that referenced
this issue
May 1, 2023
…tumlib#4324) Adds better error messaging when deprecated module can't be imported. Now, `import cirq` prints zero warnings, even if there are errors importing the modules. Instead, when the deprecated modules are used, an informative error is thrown, including the root cause error: When `cirq_pasqal` can't be imported, `import cirq.pasqal` results in: ``` Traceback (most recent call last): File "/Users/balintp/dev/proj/Cirq/cirq-core/cirq/_compat.py", line 590, in deprecated_submodule new_module = importlib.import_module(new_module_name) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked ModuleNotFoundError: No module named 'cirq_pasqal' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "<string>", line 1, in <module> File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 971, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 914, in _find_spec File "/Users/balintp/dev/proj/Cirq/cirq-core/cirq/_compat.py", line 504, in find_spec raise self.broken_module_exception cirq._compat.DeprecatedModuleImportError: cirq_pasqal cannot be imported. The typical reasons are that 1.) cirq_pasqal is not installed, or 2.) when developing Cirq, you don't have your PYTHONPATH setup. In this case run `source dev_tools/pypath`. You can check the detailed exception above for more details or run `import cirq_pasqal to reproduce the issue. ``` Note that `from cirq import pasqal` will still run and return a dummy module that will throw the same error when trying to access any of its attributes. Fixes quantumlib#4106. Fixes quantumlib#4291.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area/imports
area/install
area/packages
kind/bug-report
Something doesn't seem to work.
triage/accepted
there is consensus amongst maintainers that this is a real bug or a reasonable feature to add
Description of the issue
We produce an ugly warning that cirq_google is missing if the user only installs cirq-core.
How to reproduce the issue
pip install cirq-core
python -c 'import cirq'
Cirq version
v0.11
The text was updated successfully, but these errors were encountered: