From f31318b7f4a9925ef055545b967c270bdaea8e84 Mon Sep 17 00:00:00 2001 From: yanyongyu Date: Mon, 22 Feb 2021 10:44:42 +0800 Subject: [PATCH] :children_crossing: wrap version with try --- nonebot/__init__.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/nonebot/__init__.py b/nonebot/__init__.py index efe6ed81..9c65b5a0 100644 --- a/nonebot/__init__.py +++ b/nonebot/__init__.py @@ -36,9 +36,14 @@ from nonebot.utils import escape_tag from nonebot.config import Env, Config from nonebot.log import logger, default_filter -_dist: pkg_resources.Distribution = pkg_resources.get_distribution("nonebot2") -__version__ = _dist.version -VERSION = _dist.parsed_version +try: + _dist: pkg_resources.Distribution = pkg_resources.get_distribution( + "nonebot2") + __version__ = _dist.version + VERSION = _dist.parsed_version +except pkg_resources.DistributionNotFound: + __version__ = None + VERSION = None _driver: Optional[Driver] = None