Glitch in html5lib? - python

I'm getting this error. Is it a bug or is it a code error? What does it mean?
Traceback (most recent call last):
File "isc.py", line 8, in <module>
import requests, os, sys, bs4
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/bs4/__init__.py", line 30, in <module>
from .builder import builder_registry, ParserRejectedMarkup
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/bs4/builder/__init__.py", line 314, in <module>
from . import _html5lib
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/bs4/builder/_html5lib.py", line 70, in <module>
class TreeBuilderForHtml5lib(html5lib.treebuilders._base.TreeBuilder):
AttributeError: module 'html5lib.treebuilders' has no attribute '_base'
(i upgraded html5lib bs4 and requests)

It's an issue related to your html5lib package version try upgrading it.

Related

Getting "ImportError: cannot import name 'HTMLParseError' from 'html.parser'" with bs4

I'm on windows 10 using python 3.8.2 and got this problem when I try to run from bs4 import BeautifulSoup I get the following:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Cesar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\bs4\__init__.py", line 29, in <module>
from .builder import builder_registry
File "C:\Users\Cesar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\bs4\builder\__init__.py", line 294, in <module>
from . import _htmlparser
File "C:\Users\Cesar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\bs4\builder\_htmlparser.py", line 7, in <module>
from html.parser import (
**ImportError: cannot import name 'HTMLParseError' from 'html.parser'** (C:\Users\Cesar\AppData\Local\Programs\Python\Python38-32\lib\html\parser.py)
>>>
I've install and uninstall bs4 several times and still got the same error
what would you recommend?

Error in importing requests module in python3

I am using requests module in my python program. It worked great in the previous day. But now, when importing requests module, it is showing a weird error. It is working great in python2 version. But shows error in python3. I googled it but can't find a solution. I haven't changed anything. Why it is showing this error.
Here it is:
>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/paulsteven/.local/lib/python3.5/site-packages/requests/__init__.py", line 95, in <module>
from urllib3.contrib import pyopenssl
File "/home/paulsteven/.local/lib/python3.5/site-packages/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/home/paulsteven/.local/lib/python3.5/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/home/paulsteven/.local/lib/python3.5/site-packages/OpenSSL/rand.py", line 11, in <module>
from OpenSSL._util import (
File "/home/paulsteven/.local/lib/python3.5/site-packages/OpenSSL/_util.py", line 3, in <module>
from cryptography.hazmat.bindings.openssl.binding import Binding
File "/home/paulsteven/.local/lib/python3.5/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 188, in <module>
_verify_package_version(cryptography.__version__)
File "/home/paulsteven/.local/lib/python3.5/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 175, in _verify_package_version
so_package_version = ffi.string(lib.CRYPTOGRAPHY_PACKAGE_VERSION)
AttributeError: cffi library '_openssl' has no function, constant or global variable named 'CRYPTOGRAPHY_PACKAGE_VERSION'
Reinstalling cryptography package will resolve this problem.

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

Errors importing BeautifulSoup4

I am trying to import BeautifulSoup4, but am running into importation issues.
I am running Python 2.7.9 as 32 bit Windows (MSC v.1500)
I attempted to install BeautifulSoup4 as both a tarball and using pip. Both attempts have "installed" bs4, but import bs4 yields:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\ArcGIS10.2\lib\site-packages\bs4\__init__.py", line 29, in <module>
from .builder import builder_registry
File "C:\Python27\ArcGIS10.2\lib\site-packages\bs4\builder\__init__.py", line 294, in <module>
from . import _htmlparser
File "C:\Python27\ArcGIS10.2\lib\site-packages\bs4\builder\_htmlparser.py", line 7, in <module>
from HTMLParser import (
File "C:\Python27\ArcGIS10.2\lib\HTMLParser.py", line 47, in <module>
""", re.VERBOSE)
File "C:\Python27\ArcGIS10.2\lib\re.py", line 190, in compile
return _compile(pattern, flags)
File "C:\Python27\ArcGIS10.2\lib\re.py", line 242, in _compile
raise error, v # invalid expression
sre_constants.error: nothing to repeat
I have no idea how to fix this. Any help would be appreciated.
Try:
from bs4 import BeautifulSoup

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