我在使用命令python3运行带有environs包的python脚本时遇到问题
例如,脚本名为envir.py,我用以下命令调用它:
python3 envir.py
这将产生以下错误:
Traceback (most recent call last):
File "envir.py", line 2, in <module>
from environs import Env
File "/home/zarko/.local/lib/python3.5/site-packages/environs.py",
line 24, in <module>
Subcast = typing.Union[typing.Type, typing.Callable[..., T]]
File "/usr/lib/python3.5/typing.py", line 552, in __getitem__
dict(self.__dict__), parameters, _root=True)
File "/usr/lib/python3.5/typing.py", line 512, in __new__
for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
File "/usr/lib/python3.5/typing.py", line 512, in <genexpr>
for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
File "/usr/lib/python3.5/typing.py", line 1077, in
__subclasscheck__
if super().__subclasscheck__(cls):
File "/usr/lib/python3.5/abc.py", line 225, in __subclasscheck__
for scls in cls.__subclasses__():
TypeError: descriptor '__subclasses__' of 'type' object needs an argument
如果我使用“ python”命令来运行脚本,那么它将正常工作
这是脚本的样子
from environs import Env
env = Env()
env.read_env()
ACCESS_KEY = env("ACCESS_KEY")