Python Forum

Full Version: hypothesis 6.46.2 requires python3.7 or later
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I run the code using charm crypto for a project, python3.6 and Ununtu18 which shows me an error indicating a hypothesis and exception error.
hypothesis 6.46.2 requires python3.7 or later
The hypothesis is an advanced library in python used for testing
Where I had installed these libraries
pyparsing==2.1.5
hypothesis
pytest

The error in setup.py files or elsewhere like it can happen if the packaging toolchain is older than python require how to solve it.
from hypothesis.strategies import text, composite, sampled_from, characters, one_of, integers
from functools import partial
Error:
/usr/bin/python3.6 /home/ali/Downloads/charm-dev/charm/toolbox/policy_expression_spec.py Traceback (most recent call last): File "/home/ali/Downloads/charm-dev/charm/toolbox/policy_expression_spec.py", line 1, in <module> from hypothesis.strategies import text, composite, sampled_from, characters, one_of, integers File "/usr/local/lib/python3.6/dist-packages/hypothesis-6.46.2-py3.6.egg/hypothesis/__init__.py", line 18, in <module> import hypothesis._error_if_old # noqa # imported for side-effect of nice error File "/usr/local/lib/python3.6/dist-packages/hypothesis-6.46.2-py3.6.egg/hypothesis/_error_if_old.py", line 23, in <module> raise Exception(message.format(__version__)) Exception: Hypothesis 6.46.2 requires Python 3.7 or later. This can only happen if your packaging toolchain is older than python_requires. See https://packaging.python.org/guides/distributing-packages-using-setuptools/ Error in sys.excepthook: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 62, in apport_excepthook if not enabled(): File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 24, in enabled import re File "/usr/lib/python3.6/re.py", line 142, in <module> class RegexFlag(enum.IntFlag): AttributeError: module 'enum' has no attribute 'IntFlag' Original exception was: Traceback (most recent call last): File "/home/ali/Downloads/charm-dev/charm/toolbox/policy_expression_spec.py", line 1, in <module> from hypothesis.strategies import text, composite, sampled_from, characters, one_of, integers File "/usr/local/lib/python3.6/dist-packages/hypothesis-6.46.2-py3.6.egg/hypothesis/__init__.py", line 18, in <module> import hypothesis._error_if_old # noqa # imported for side-effect of nice error File "/usr/local/lib/python3.6/dist-packages/hypothesis-6.46.2-py3.6.egg/hypothesis/_error_if_old.py", line 23, in <module> raise Exception(message.format(__version__)) Exception: Hypothesis 6.46.2 requires Python 3.7 or later. This can only happen if your packaging toolchain is older than python_requires. See https://packaging.python.org/guides/distributing-packages-using-setuptools/
The message is very clear,you are using Python 3.6 and Hypothesis requires Python 3.7 or later.
Install a new Python version eg now Python 3.10.5.
Many libraries start drooping support for Python 3.6.
for the new version, of python I know it works I know how to solve it in python3.6
Which Linux-Distribution are you using?
Debian has never used Python 3.6 in any release.

On Linux, you have the problem, that often a major version is fixed and could not be replaced by a newer version, but you can use pyenv to build your own Python versions, which are isolated from the rest of your system.

https://realpython.com/intro-to-pyenv/

If you like, you can also compile alpha/beta Versions like Python 3.11.0b3
I am using Ubuntu 18 and python 3.6 but if I change it new python version then the problem is with charm and PBC and PyPBC need to install for the new version and other problems are charm-based implementation https://github.com/JHUISI/charm/tree/dev/charm/test of some code support python3.6 and some code python3.7 or above.
Whenever python is changed, python packages that are not included with the distribution must be replaced.
This should be expected, as there are as of today 383,326 packages available and it wouldn't be practical nor wise to do so.

Re-Installing packages doesn't take long using pip.

Note: Commands shown are for Linux, may be different for MSwindows

You can expedite this by having a requirements file pip freeze > requirements.txt available prior to removing old python version.

Then after new version is installed and version selected, you can run pip install -r requirements.txt which will reinstall all packages (including the same version number as before).

DeaD_Eye's suggestion of installing pyenv is the way to go (In my opinion). I use it in combination with a virtual environment for every new project I create.
@DeaD_EyE and @Larz60+ sure thanks you for your time and suggestion.