Skip to content
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

Backport PR #23377 on branch 6.x (PR: Improve message when a variable can't be viewed due to a missing module (Variable Explorer)) #23584

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion spyder/plugins/ipythonconsole/widgets/namespacebrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from spyder_kernels.comms.commbase import CommError

# Local imports
from spyder.config.base import _
from spyder.config.base import _, is_conda_based_app

# For logging
logger = logging.getLogger(__name__)
Expand All @@ -42,6 +42,16 @@ def get_value(self, name):
reason_other = _("An unkown error occurred. Check the console because "
"its contents could have been printed there")
reason_comm = _("The comm channel is not working")
reason_missing_package_installer = _(
"The '{}' package is required to open this variable. "
"Unfortunately, it's not part of our installer, which means your "
"variable can't be displayed by Spyder."
)
reason_missing_package = _(
"The '{}' package is required to open this variable and it's not "
"installed alongside Spyder. To fix this problem, please install "
"it in the same environment that you use to run Spyder."
)
msg = _("<br><i>%s.</i><br><br><br>"
"<b>Note</b>: Please don't report this problem on Github, "
"there's nothing to do about it.")
Expand All @@ -63,6 +73,15 @@ def get_value(self, name):
raise
except CommError:
raise ValueError(msg % reason_comm)
except ModuleNotFoundError as e:
if is_conda_based_app():
raise ValueError(
msg % reason_missing_package_installer.format(e.name)
)
else:
raise ValueError(
msg % reason_missing_package.format(e.name)
)
except Exception:
raise ValueError(msg % reason_other)

Expand Down
Loading