From 71bf1d114775db4a11b08288899743638f3ff741 Mon Sep 17 00:00:00 2001 From: Ju4tCode <42488585+yanyongyu@users.noreply.github.com> Date: Mon, 1 Aug 2022 10:52:15 +0800 Subject: [PATCH] :bug: fix import error if setuptools not installed (#1116) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix: 修复 setuptools 未安装导致 ImportError --- nonebot/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nonebot/__init__.py b/nonebot/__init__.py index e9195a71..e3301109 100644 --- a/nonebot/__init__.py +++ b/nonebot/__init__.py @@ -40,8 +40,6 @@ FrontMatter: import importlib from typing import Any, Dict, Type, Optional -import pkg_resources - from nonebot.adapters import Bot from nonebot.utils import escape_tag from nonebot.config import Env, Config @@ -49,10 +47,12 @@ from nonebot.log import logger, default_filter from nonebot.drivers import Driver, ReverseDriver, combine_driver try: + import pkg_resources + _dist: pkg_resources.Distribution = pkg_resources.get_distribution("nonebot2") __version__ = _dist.version VERSION = _dist.parsed_version -except pkg_resources.DistributionNotFound: # pragma: no cover +except Exception: # pragma: no cover __version__ = None VERSION = None