Module error with Werkzeug 0.7 - python

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

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'

SSL Protocol error with flask app

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

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

Unable to install Flask SQLAlchemy

While trying to make attempt of installing it i get following error. What am I missing?
Install packages failed: Error occurred when installing package Flask-SQLAlchemy.
The following command was executed:
packaging_tool.py install --build-dir /private/var/folders/4B/4Bd6e77uH-uNGxBS-xhds++++TI/-Tmp-/pycharm-packaging5175396548329498703.tmp Flask-SQLAlchemy
The error output of the command:
Error: Traceback (most recent call last):
File "/Applications/PyCharm.app/helpers/packaging_tool.py", line 54, in do_install
import pip
File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/__init__.py", line 10, in <module>
from pip.util import get_installed_distributions, get_prog
File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/util.py", line 18, in <module>
from pip._vendor.distlib import version
File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/_vendor/distlib/version.py", line 14, in <module>
from .compat import string_types
File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/_vendor/distlib/compat.py", line 31, in <module>
from urllib2 import (Request, urlopen, URLError, HTTPError,
ImportError: cannot import name HTTPSHandler
Here is the SO question got several answers Python ImportError: cannot import name HTTPSHandler.
Which in general, check if you have ssl module, and OpenSSL header files installed.

Python error importing module pandas "name 'GET' is not defined"

I have the most updated numpy, httplib2, pytz, Cython, python-dateutil & numexpr
And newest pandas build
But I'm flummoxed! The following code gives the following rather cryptic error. What is it trying to tell me?
import pandas
print "ok pandas"
error:
Traceback (most recent call last):
File "sank.py", line 1, in <module>
import pandas
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas-0.14.1-py2.7-macosx-10.6-intel.egg/pandas/__init__.py", line 45, in <module>
from pandas.io.api import *
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas-0.14.1-py2.7-macosx-10.6-intel.egg/pandas/io/api.py", line 15, in <module>
from pandas.io.gbq import read_gbq
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas-0.14.1-py2.7-macosx-10.6-intel.egg/pandas/io/gbq.py", line 59, in <module>
import httplib2
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/httplib2-0.9-py2.7.egg/httplib2/__init__.py", line 1070, in <module>
from google.appengine.api import apiproxy_stub_map
File "/Users/maggielee/Documents/pythons/google.py", line 32, in <module>
GET / HTTP/1.0
NameError: name 'GET' is not defined
Solution by furas and OP.
I had an old file called google.py. Just renamed/deleted it and problem was solved.
Probably python uses this file when it imports from google.appengine.api.

Categories