SSL Protocol error with flask app - python

I've been trying to run a simple flask app but I'm getting the following error.
from flask import Flask
app = Flask(__name__)
#app.route('/')
def hello_world():
return 'Hello, World!'
I'm running it as python app.py, sudo python app.py but the same error is always popping up
Traceback (most recent call last):
File "app.py", line 1, in <module>
from flask import Flask
File "/usr/local/lib/python2.7/site-packages/flask/__init__.py", line 17, in <module>
from werkzeug.exceptions import abort
File "/usr/local/lib/python2.7/site-packages/werkzeug/__init__.py", line 152, in <module>
__import__('werkzeug.exceptions')
File "/usr/local/lib/python2.7/site-packages/werkzeug/exceptions.py", line 71, in <module>
from werkzeug.wrappers import Response
File "/usr/local/lib/python2.7/site-packages/werkzeug/wrappers.py", line 26, in <module>
from werkzeug.http import HTTP_STATUS_CODES, \
File "/usr/local/lib/python2.7/site-packages/werkzeug/http.py", line 26, in <module>
from urllib2 import parse_http_list as _parse_list_header
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 94, in <module>
import httplib
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1230, in <module>
import ssl
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 133, in <module>
PROTOCOL_SSLv23 = PROTOCOL_TLS
NameError: name 'PROTOCOL_TLS' is not defined
Help is appreciated, thanks!

Completely uninstalled python and all it's dependencies and it worked.

This error appears to occur when a you have an outdated OpenSSL or PyOpenSSL version. Updating PyOpenSSL should fix this issue:
pip install --upgrade pyopenssl

Related

Airflow Webpage to lauch

when trying to run the command: airflow webserver - i get the below error message
i am having issues getting the application to launch.
python 3.8.0
postgress latest version
Airflow Latest Version
we are having troubles finding an answer to this in the forums / through basic google searching, thank you in advance!
~$ airflow webserver
Traceback (most recent call last):
File "/usr/local/bin/airflow", line 5, in <module>
from airflow.__main__ import main
File "/usr/local/lib/python3.8/dist-packages/airflow/__init__.py", line 34, in <module>
from airflow import settings
File "/usr/local/lib/python3.8/dist-packages/airflow/settings.py", line 35, in <module>
from airflow.configuration import AIRFLOW_HOME, WEBSERVER_CONFIG, conf # NOQA F401
File "/usr/local/lib/python3.8/dist-packages/airflow/configuration.py", line 1115, in <module>
conf = initialize_config()
File "/usr/local/lib/python3.8/dist-packages/airflow/configuration.py", line 829, in initialize_config
from cryptography.fernet import Fernet
File "/usr/lib/python3/dist-packages/cryptography/fernet.py", line 17, in <module>
from cryptography.hazmat.primitives import hashes, padding
File "/usr/lib/python3/dist-packages/cryptography/hazmat/primitives/padding.py", line 13, in <module>
from cryptography.hazmat.bindings._padding import lib
ModuleNotFoundError: No module named '_cffi_backend'

ImportError: cannot import name 'UserAgentMixin'

I've got an issue when I want to init my Flask DB, here is Terminal result :
user#Pc:~/Documents/test$ flask db init
Traceback (most recent call last):
File "/home/user/.local/bin/flask", line 7, in <module>
from flask.cli import main
File "/home/user/.local/lib/python3.6/site-packages/flask/__init__.py", line 17, in <module>
from werkzeug.exceptions import abort
File "/home/user/.local/lib/python3.6/site-packages/werkzeug/__init__.py", line 151, in <module>
__import__('werkzeug.exceptions')
File "/home/user/.local/lib/python3.6/site-packages/werkzeug/exceptions.py", line 71, in <module>
from werkzeug.wrappers import Response
File "/home/user/.local/lib/python3.6/site-packages/werkzeug/wrappers/__init__.py", line 30, in <module>
from .request import PlainRequest
File "/home/user/.local/lib/python3.6/site-packages/werkzeug/wrappers/request.py", line 6, in <module>
from .user_agent import UserAgentMixin
File "/home/user/.local/lib/python3.6/site-packages/werkzeug/wrappers/user_agent.py", line 1, in <module>
from ..useragents import UserAgent
File "/home/user/.local/lib/python3.6/site-packages/werkzeug/useragents.py", line 212, in <module>
from werkzeug.wrappers import UserAgentMixin # noqa
ImportError: cannot import name 'UserAgentMixin'
I'm working on an Ubuntu 18.04 LTS, using Flask, SQLAlchemy, Python and PostgreSQL. From where does this error occurs, and how can I solve it?
P.S : I followed the mega tutorial about Flask
EDIT 1 : Werkzeug is already installed
(venv) user#Pc:~/Documents/test$ pip install Werkzeug
Requirement already satisfied: Werkzeug in ./venv/lib/python3.6/site-packages
EDIT 2 : I don't know why I got this issue, but this error disappear after I removed spaces indentations
Try pip install Werkzeug
UserAgentMixin is from werkzeug!
ref: https://tedboy.github.io/flask/generated/generated/werkzeug.UserAgentMixin.html
in my case, I found a file and a folder, both named "wrappers" in the package path, so I reinstall the package:
pip uninstall Werkzeug
pip install Werkzeug
though a little late, it may still help

Module error with Werkzeug 0.7

I try to learn flask with some basic examplse, but even with the example on the original flask website, i get an error coming from Werkzeug http.py.
Here is the code:
from flask import Flask
app = Flask(__name__)
#app.route('/')
def hello_world():
return 'Hello, World!'
Here is the error: https://pastebin.com/7N1TP0zm
Traceback (most recent call last):
File "C:\Program Files\Python36\lib\site-packages\werkzeug\http.py", line 26, in <module>
from urllib.request import parse_http_list as _parse_list_header
File "C:\Program Files\Python36\lib\urllib\request.py", line 88, in <module>
import http.client
File "C:\Users\Adrien\Desktop\http.py", line 1, in <module>
from flask import Flask
ImportError: cannot import name 'Flask'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Adrien\Desktop\http.py", line 1, in <module>
from flask import Flask
File "C:\Program Files\Python36\lib\site-packages\flask\__init__.py", line 17, in <module>
from werkzeug.exceptions import abort
File "C:\Program Files\Python36\lib\site-packages\werkzeug\__init__.py", line 151, in <module>
__import__('werkzeug.exceptions')
File "C:\Program Files\Python36\lib\site-packages\werkzeug\exceptions.py", line 71, in <module>
from werkzeug.wrappers import Response
File "C:\Program Files\Python36\lib\site-packages\werkzeug\wrappers.py", line 26, in <module>
from werkzeug.http import HTTP_STATUS_CODES, \
File "C:\Program Files\Python36\lib\site-packages\werkzeug\http.py", line 29, in <module>
from urllib2 import parse_http_list as _parse_list_header, \
ModuleNotFoundError: No module named 'urllib2'
additional informations:
i'm on windows 7 64 bit
i use python 3.6 64 bit
the Werkzeug version seems to be 0.12.2
I tried unistalling and installing python multiple times, but it don't help.
Thanks in advance for you help.
EDIT:
when in try to install urllib2 i get this error:
Could not find a version that satisfies the requierement urllib2 (from versions: )
No matching distribution found for urllib2

Jupyter Noterbook error

I just cannot use jupyter notebook. I have updated to the most recent version by ananota, and it still does not work.
The error message is listed below:
C:\Users\willian>jupyter notebook
Traceback (most recent call last):
File "C:\Anaconda3\Scripts\jupyter-notebook-script.py", line 3, in <module>
import notebook.notebookapp
File "C:\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 40, in <module>
ioloop.install()
File "C:\Anaconda3\lib\site-packages\zmq\eventloop\ioloop.py", line 207, in install
from tornado import ioloop
File "C:\Anaconda3\lib\site-packages\tornado\ioloop.py", line 47, in <module>
from tornado.concurrent import TracebackFuture, is_future
File "C:\Anaconda3\lib\site-packages\tornado\concurrent.py", line 34, in <module>
from tornado.util import raise_exc_info, ArgReplacer, is_finalizing
ImportError: cannot import name 'is_finalizing'
From your error it looks like the tornado package is not installed in your environment. Installing tornado with the command below should fix your problem.
pip install tornado

Python error while installing using homebrew

Hi I installed python using "homebrew install python".
A script which was already running started throwing below error.
Traceback (most recent call last):
File "TestConnection.py", line 1, in <module>
from TextUpdater import TextUpdater
File "/Users/gepaul/code/external-tools/tools/Scripts/TextUpdater.py", line 1, in <module>
from GSHelper import GSHelper
File "/Users/gepaul/code/external-tools/tools/Scripts/GSHelper.py", line 2, in <module>
import gspread
File "/Library/Python/2.7/site-packages/gspread/__init__.py", line 21, in <module>
from .client import Client, login, authorize
File "/Library/Python/2.7/site-packages/gspread/client.py", line 19, in <module>
from .httpsession import HTTPSession, HTTPError
File "/Library/Python/2.7/site-packages/gspread/httpsession.py", line 16, in <module>
from http import client
ImportError: cannot import name client
Any Idea why this happened?
Python version is Python 2.7.6

Categories