使用flask run
时出现此错误。
Traceback (most recent call last):
File "/Users/xuye/anaconda/bin/flask", line 11, in <module>
sys.exit(main())
File "/Users/xuye/anaconda/lib/python2.7/site-packages/flask/cli.py", line 894, in main
cli.main(args=args, prog_name=name)
File "/Users/xuye/anaconda/lib/python2.7/site-packages/flask/cli.py", line 557, in main
return super(FlaskGroup, self).main(*args, **kwargs)
File "/Users/xuye/anaconda/lib/python2.7/site-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/Users/xuye/anaconda/lib/python2.7/site-packages/click/core.py", line 1135, in invoke
sub_ctx = cmd.make_context(cmd_name, args, parent=ctx)
File "/Users/xuye/anaconda/lib/python2.7/site-packages/click/core.py", line 641, in make_context
self.parse_args(ctx, args)
File "/Users/xuye/anaconda/lib/python2.7/site-packages/click/core.py", line 940, in parse_args
value, args = param.handle_parse_result(ctx, opts, args)
File "/Users/xuye/anaconda/lib/python2.7/site-packages/click/core.py", line 1477, in handle_parse_result
self.callback, ctx, self, value)
File "/Users/xuye/anaconda/lib/python2.7/site-packages/click/core.py", line 96, in invoke_param_callback
return callback(ctx, param, value)
File "/Users/xuye/anaconda/lib/python2.7/site-packages/flask/cli.py", line 693, in _validate_key
is_context = isinstance(cert, ssl.SSLContext)
AttributeError: 'module' object has no attribute 'SSLContext'
我已经搜索并更新了我的Python版本到2.7.15,但是它不起作用。
答案 0 :(得分:0)
我遇到了同样的错误,我认为这是我在激活虚拟环境的情况下安装了flask和MarkupSafe(需要升级)。我要解决的是在新终端安装烧瓶和Markupsafe并重新启动venv的情况下卸载flask和MarkupSafe,然后关闭cmd,然后激活虚拟环境。那对我有用!
答案 1 :(得分:0)
在使用Anaconda(Python3于2020年4月最新版)和虚拟环境时,我也遇到了此错误。要摆脱错误:
导航到所需的虚拟环境venv /脚本
cd ... / myvenv / Scripts
激活您的虚拟环境
激活
重新运行烧瓶运行
烧瓶运行
答案 2 :(得分:0)
选择anaconda作为项目解释器中的虚拟环境为我工作,我也将其从anaconda文件中删除并进行了烧瓶处理