我有lxml但仍然要求我安装它

时间:2016-07-15 22:59:27

标签: python http lxml

我有lxml,因为我使用

检查了它
`import pandas as pd `

`pd.show_versions(as_json=False)`

我有lxml版本3.6.0,这是“已安装的版本”

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.12.final.0
python-bits: 64
OS: Linux
OS-release: 3.19.0-64-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.18.0
nose: 1.3.7
pip: 8.1.2
setuptools: 20.3
Cython: 0.23.4
numpy: 1.10.4
 scipy: 0.17.0
statsmodels: 0.6.1
xarray: None
IPython: 4.1.2
sphinx: 1.3.5
patsy: 0.4.0
dateutil: 2.5.1
pytz: 2016.2
blosc: None
bottleneck: 1.0.0
tables: 3.2.2
numexpr: 2.5
matplotlib: 1.5.1
openpyxl: 2.3.2
xlrd: 0.9.4
xlwt: 1.0.0
xlsxwriter: 0.8.4
lxml: 3.6.0
bs4: None
html5lib: 0.999999999
httplib2: None
apiclient: None
sqlalchemy: 1.0.12
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.39.0

但是当我试图跑

table_list = pd.read_html("http://www.psmsl.org/data/obtaining/")

我得到了这个按摩

              ---------------------------------------------------------------------------
    AttributeError                            Traceback (most recent call last)
    <ipython-input-13-5f8ed046a27a> in <module>()
           1 # Needs `lxml`, `beautifulSoup4` and `html5lib` python packages
           2 # Local backup in data/sea_levels/Obtaining Tide Gauge Data.html
    ----> 3 table_list = pd.read_html("http://www.psmsl.org/data/obtaining/")

    /home/ola/anaconda2/lib/python2.7/site-packages/pandas/io/html.pyc in read_html(io, match, flavor, header, index_col, skiprows, attrs, parse_dates, tupleize_cols, thousands, encoding)
    859     pandas.read_csv
    860     """
 --> 861     _importers()
    862 
    863     # Type check here. We don't want to parse only to fail because of an

/home/ola/anaconda2/lib/python2.7/site-packages/pandas/io/html.pyc in _importers()
     40 
     41     try:
---> 42         import bs4  # noqa
     43         _HAS_BS4 = True
     44     except ImportError:

/home/ola/anaconda2/lib/python2.7/site-packages/bs4/__init__.py in <module>()
     28 import warnings
     29 
---> 30 from .builder import builder_registry, ParserRejectedMarkup
     31 from .dammit import UnicodeDammit
     32 from .element import (

/home/ola/anaconda2/lib/python2.7/site-packages/bs4/builder/__init__.py in <module>()
    312 register_treebuilders_from(_htmlparser)
    313 try:
--> 314     from . import _html5lib
    315     register_treebuilders_from(_html5lib)
    316 except ImportError:

 /home/ola/anaconda2/lib/python2.7/site-packages/bs4/builder/_html5lib.py in <module>()
     68 
     69 
 ---> 70 class   TreeBuilderForHtml5lib(html5lib.treebuilders._base.TreeBuilder):
     71 
     72     def __init__(self, soup, namespaceHTMLElements):

AttributeError: 'module' object has no attribute '_base'

我该怎么办?知道我试过这个命令      conda install -c anaconda lxml = 3.6.0 我按摩了这个按摩

The following packages will be UPDATED:

        conda-env: 2.5.0-py27_0 anaconda --> 2.5.2-py27_0 anaconda

The following packages will be SUPERCEDED by a higher-priority channel:

    lxml:      3.6.0-py27_0          --> 3.6.0-py27_0 anaconda

Proceed ([y]/n)? y

Pruning fetched packages from the cache ...
Fetching packages ...
Could not connect to https://conda.anaconda.org/anaconda/linux-64/conda-env-2.5.2-py27_0.tar.bz2
Error: Connection error: HTTPSConnectionPool(host='conda.anaconda.org', port=443): Max retries exceeded with url: /anaconda/linux-64/conda-env-2.5.2-py27_0.tar.bz2 (Caused by  NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f7f6c0ac810>: Failed to establish a new connection: [Errno -2] Name or service not known',)): https://conda.anaconda.org/anaconda/linux-64/conda-env-2.5.2-py27_0.tar.bz2

1 个答案:

答案 0 :(得分:0)

我看到您报告的两个问题:

  1. 您在访问anaconda.org时遇到问题。尝试ping它以查看它是否已关闭,检查您的连接,和/或查看该服务是否暂时停止...
  2. 我已经在Anaconda-Python3.5和Canopy1.7(Python 2.7)上进行了测试,并且两者都使用了lxml 3.6html5lib 0.999。您有相同的lxml但似乎有不同版本的html5lib。
  3. 您最好的选择是更新html5lib,尝试更新lxml(如果这还不够),或者如果不起作用,请向Continuum报告问题。 2在他们的包装解析中可能存在一些不兼容性。同时,如果你想留在Python2上,可以试试Anaconda-Python3.5或Canopy1.7(见tutorial instructions)。