-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add warning on Aer and IBMQ ImportError #2842
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
Merged
mtreinish
merged 14 commits into
Qiskit:master
from
mtreinish:warn-on-missing-namespace
Aug 13, 2019
Merged
Add warning on Aer and IBMQ ImportError #2842
mtreinish
merged 14 commits into
Qiskit:master
from
mtreinish:warn-on-missing-namespace
Aug 13, 2019
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This commit adds a warning whenever qiskit is imported if it can't import qiskit-aer or qiskit-ibmq-provider. Right now if a user installs terra and either does not install aer or the ibmq-provider, or also equally as likely installs them but python packaging messes up the namespace and there is no indication that these features are missing until they go to use qiskit.Aer, or qiskit.IBMQ. To address this commit adds a warning that will only be displayed once on the first import of anything from the qiskit namespace in a python process, using python's stdlib warning mechanism (which is configurable and suppressible). This will hopefully remove the surprise when users try to use Aer or IBMQ like in documentation and tutorials and they just get an empty AttributeError. Related Qiskit#2483
These read a bit odd. Perhaps: Could not import the Aer provider from the qiskit-aer package. Could not import the IBMQ account from the qiskit-ibmq-provider package. |
kdk
reviewed
Aug 7, 2019
kdk
approved these changes
Aug 13, 2019
mtreinish
added a commit
to mtreinish/qiskit-core
that referenced
this pull request
Aug 13, 2019
Recently we started emitting on failed imports for IBMQ and Aer in Qiskit#2842 to tell users if they have a misconfigured or missing qiskit-aer or qiskit-ibmq-provider package. However, in that PR we set the warning class to ImportWarning which is ignored by default in python. This defeats the whole purpose of emitting the warning because no one will see it unless they explicit enable printing ImportWarnings to stderr. ImportWarning was chosen because it seems to map the best to what we're warning about and provides a unique enough class that is easy to filter for those users who do not wish to install either Aer or IBMQ. This commit changes the warning class to RuntimeWarning so that it will show by default but still meet the criteria that we original chose ImportWarning based on.
mtreinish
added a commit
that referenced
this pull request
Aug 14, 2019
Recently we started emitting on failed imports for IBMQ and Aer in #2842 to tell users if they have a misconfigured or missing qiskit-aer or qiskit-ibmq-provider package. However, in that PR we set the warning class to ImportWarning which is ignored by default in python. This defeats the whole purpose of emitting the warning because no one will see it unless they explicit enable printing ImportWarnings to stderr. ImportWarning was chosen because it seems to map the best to what we're warning about and provides a unique enough class that is easy to filter for those users who do not wish to install either Aer or IBMQ. This commit changes the warning class to RuntimeWarning so that it will show by default but still meet the criteria that we original chose ImportWarning based on.
mtreinish
added a commit
to mtreinish/qiskit
that referenced
this pull request
Aug 14, 2019
This commit adds details to the install guide and the install from source guide on new warnings being emitted by terra in the 0.9 release. Added in Qiskit/qiskit#2842 when qiskit-aer or qiskit-ibmq-provider can not be found by terra on initial import it will emit a warning to inform the user of that state. This is done because today the user will have no idea if they forgot to install these components (or more likely python packaging screwed up the installation) and aer or ibmq can't be found. They will then try to use either qiskit.Aer or qiskit.IBMQ only to be met by a confusing ImportError. This is a very common occurrence for users and causes a great deal of confusion. However, since emitting a warning on import is potentially undesirable behavior for any users that only use qiskit-terra by itself. If they never have any intent of importing qiskit.Aer or qiskit.IBMQ then emitting a warning is fairly annoying. This commit documents these warnings and more importantly how to suppress them for these users, so that they do not have to be concerned about seeing the warnings in perpetuity moving forward if they do not want to. This updates both the install guide and the contributing guide since it's conceivable a user would refer to either guide when installing terra as a standalone component. At the same time a stale reference to a warning that as of Qiskit#304 merging no longer will be emitted when installing the qiskit metapackage is removed from the install documentation.
jaygambetta
pushed a commit
to Qiskit/qiskit-metapackage
that referenced
this pull request
Aug 14, 2019
This commit adds details to the install guide and the install from source guide on new warnings being emitted by terra in the 0.9 release. Added in Qiskit/qiskit#2842 when qiskit-aer or qiskit-ibmq-provider can not be found by terra on initial import it will emit a warning to inform the user of that state. This is done because today the user will have no idea if they forgot to install these components (or more likely python packaging screwed up the installation) and aer or ibmq can't be found. They will then try to use either qiskit.Aer or qiskit.IBMQ only to be met by a confusing ImportError. This is a very common occurrence for users and causes a great deal of confusion. However, since emitting a warning on import is potentially undesirable behavior for any users that only use qiskit-terra by itself. If they never have any intent of importing qiskit.Aer or qiskit.IBMQ then emitting a warning is fairly annoying. This commit documents these warnings and more importantly how to suppress them for these users, so that they do not have to be concerned about seeing the warnings in perpetuity moving forward if they do not want to. This updates both the install guide and the contributing guide since it's conceivable a user would refer to either guide when installing terra as a standalone component. At the same time a stale reference to a warning that as of #304 merging no longer will be emitted when installing the qiskit metapackage is removed from the install documentation.
faisaldebouni
pushed a commit
to faisaldebouni/qiskit-terra
that referenced
this pull request
Aug 5, 2020
* Add warning on Aer and IBMQ ImportError This commit adds a warning whenever qiskit is imported if it can't import qiskit-aer or qiskit-ibmq-provider. Right now if a user installs terra and either does not install aer or the ibmq-provider, or also equally as likely installs them but python packaging messes up the namespace and there is no indication that these features are missing until they go to use qiskit.Aer, or qiskit.IBMQ. To address this commit adds a warning that will only be displayed once on the first import of anything from the qiskit namespace in a python process, using python's stdlib warning mechanism (which is configurable and suppressible). This will hopefully remove the surprise when users try to use Aer or IBMQ like in documentation and tutorials and they just get an empty AttributeError. Related Qiskit#2483 * Update warning message * Fix review comments and change warning class
faisaldebouni
pushed a commit
to faisaldebouni/qiskit-terra
that referenced
this pull request
Aug 5, 2020
Recently we started emitting on failed imports for IBMQ and Aer in Qiskit#2842 to tell users if they have a misconfigured or missing qiskit-aer or qiskit-ibmq-provider package. However, in that PR we set the warning class to ImportWarning which is ignored by default in python. This defeats the whole purpose of emitting the warning because no one will see it unless they explicit enable printing ImportWarnings to stderr. ImportWarning was chosen because it seems to map the best to what we're warning about and provides a unique enough class that is easy to filter for those users who do not wish to install either Aer or IBMQ. This commit changes the warning class to RuntimeWarning so that it will show by default but still meet the criteria that we original chose ImportWarning based on.
jakelishman
pushed a commit
to jakelishman/qiskit-terra
that referenced
this pull request
Aug 11, 2023
…-metapackage#404) This commit adds details to the install guide and the install from source guide on new warnings being emitted by terra in the 0.9 release. Added in Qiskit#2842 when qiskit-aer or qiskit-ibmq-provider can not be found by terra on initial import it will emit a warning to inform the user of that state. This is done because today the user will have no idea if they forgot to install these components (or more likely python packaging screwed up the installation) and aer or ibmq can't be found. They will then try to use either qiskit.Aer or qiskit.IBMQ only to be met by a confusing ImportError. This is a very common occurrence for users and causes a great deal of confusion. However, since emitting a warning on import is potentially undesirable behavior for any users that only use qiskit-terra by itself. If they never have any intent of importing qiskit.Aer or qiskit.IBMQ then emitting a warning is fairly annoying. This commit documents these warnings and more importantly how to suppress them for these users, so that they do not have to be concerned about seeing the warnings in perpetuity moving forward if they do not want to. This updates both the install guide and the contributing guide since it's conceivable a user would refer to either guide when installing terra as a standalone component. At the same time a stale reference to a warning that as of Qiskit/qiskit-metapackage#304 merging no longer will be emitted when installing the qiskit metapackage is removed from the install documentation.
SameerD-phys
pushed a commit
to SameerD-phys/qiskit-terra
that referenced
this pull request
Sep 7, 2023
…-metapackage#404) This commit adds details to the install guide and the install from source guide on new warnings being emitted by terra in the 0.9 release. Added in Qiskit#2842 when qiskit-aer or qiskit-ibmq-provider can not be found by terra on initial import it will emit a warning to inform the user of that state. This is done because today the user will have no idea if they forgot to install these components (or more likely python packaging screwed up the installation) and aer or ibmq can't be found. They will then try to use either qiskit.Aer or qiskit.IBMQ only to be met by a confusing ImportError. This is a very common occurrence for users and causes a great deal of confusion. However, since emitting a warning on import is potentially undesirable behavior for any users that only use qiskit-terra by itself. If they never have any intent of importing qiskit.Aer or qiskit.IBMQ then emitting a warning is fairly annoying. This commit documents these warnings and more importantly how to suppress them for these users, so that they do not have to be concerned about seeing the warnings in perpetuity moving forward if they do not want to. This updates both the install guide and the contributing guide since it's conceivable a user would refer to either guide when installing terra as a standalone component. At the same time a stale reference to a warning that as of Qiskit/qiskit-metapackage#304 merging no longer will be emitted when installing the qiskit metapackage is removed from the install documentation.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This commit adds a warning whenever qiskit is imported if it can't
import qiskit-aer or qiskit-ibmq-provider. Right now if a user installs
terra and either does not install aer or the ibmq-provider, or also
equally as likely installs them but python packaging messes up the
namespace and there is no indication that these features are missing
until they go to use qiskit.Aer, or qiskit.IBMQ. To address this
commit adds a warning that will only be displayed once on the first
import of anything from the qiskit namespace in a python process, using
python's stdlib warning mechanism (which is configurable and
suppressible). This will hopefully remove the surprise when users try
to use Aer or IBMQ like in documentation and tutorials and they just
get an empty AttributeError.
Details and comments
Related #2483