From 68c301423291ebe80b6f8174e7f1978f5a2613f6 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 13 Dec 2023 22:20:50 +1100 Subject: [PATCH] FAQ - removeSuffix error (#6081) * Add FAQ entry about removeSuffix error - Closes https://github.com/inventree/InvenTree/issues/6080 * Check python version in tasks.py --- docs/docs/faq.md | 6 ++++++ tasks.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/docs/docs/faq.md b/docs/docs/faq.md index da2b8c4f69..5056fc0c57 100644 --- a/docs/docs/faq.md +++ b/docs/docs/faq.md @@ -51,6 +51,12 @@ Most likely you are trying to run the InvenTree server from outside the context Always activate the virtual environment before running server commands! +### 'str' object has no attribute 'removeSuffix' + +This error occurs because your installed python version is not up to date. We [require Python v3.9 or newer](./start/intro.md#python-requirements) + +You (or your system administrator) needs to update python to meet the minimum requirements for InvenTree. + ## Update Issues Sometimes, users may encounter unexpected error messages when updating their InvenTree installation to a newer version. diff --git a/tasks.py b/tasks.py index 5627b281af..4558117b6c 100644 --- a/tasks.py +++ b/tasks.py @@ -13,6 +13,35 @@ from platform import python_version from invoke import task +def checkPythonVersion(): + """Check that the installed python version meets minimum requirements. + + If the python version is not sufficient, exits with a non-zero exit code. + """ + + REQ_MAJOR = 3 + REQ_MINOR = 9 + + version = sys.version.split(" ")[0] + + valid = True + + if sys.version_info.major < REQ_MAJOR: + valid = False + + elif sys.version_info.major == REQ_MAJOR and sys.version_info.minor < REQ_MINOR: + valid = False + + if not valid: + print(f"The installed python version ({version}) is not supported!") + print(f"InvenTree requires Python {REQ_MAJOR}.{REQ_MINOR} or above") + sys.exit(1) + + +if __name__ in ['__main__', 'tasks']: + checkPythonVersion() + + def apps(): """Returns a list of installed apps.""" return [