简体   繁体   中英

Python module installation error

I tried to install a module named tushare, I have tried 3 methods: pip, easy_install and setup.py install, they all have the same error:

ImportError: No module named lxml.html

pip:

C:\WINDOWS\system32>pip install tushare
Collecting tushare
  Using cached tushare-0.6.8.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "c:\users\endeav~1\appdata\local\temp\pip-build-pkbgde\tushare\setup.py", line 4, in <module>
        import tushare
      File "tushare\__init__.py", line 6, in <module>
        from tushare.stock.trading import (get_hist_data, get_tick_data,
      File "tushare\stock\trading.py", line 13, in <module>
        import lxml.html
    ImportError: No module named lxml.html

easy_install:

C:\WINDOWS\system32>easy_install tushare
Searching for tushare
Reading https://pypi.python.org/simple/tushare/
Downloading https://pypi.python.org/packages/0a/ca/ad9eeed1c285c58d115a0dd82734e5375abf1b6e510c7c24f2f8de921c75/tushare-0.6.8.tar.gz#md5=7626d97088d93d99c1a6ece80302d617
Best match: tushare 0.6.8
Processing tushare-0.6.8.tar.gz
Writing c:\users\endeav~1\appdata\local\temp\easy_install-iisas7\tushare-0.6.8\setup.cfg
Running tushare-0.6.8\setup.py -q bdist_egg --dist-dir c:\users\endeav~1\appdata\local\temp\easy_install-iisas7\tushare-0.6.8\egg-dist-tmp-dakavz
Traceback (most recent call last):
  File "c:\python27\lib\runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
.......
  File "c:\users\endeav~1\appdata\local\temp\easy_install-iisas7\tushare-0.6.8\tushare\stock\trading.py", line 13, in <module>
ImportError: No module named lxml.html

setup.py install

C:\WINDOWS\system32>cd C:\Users\Endeavour\Desktop\tushare-0.6.8

C:\Users\Endeavour\Desktop\tushare-0.6.8>setup.py install
Traceback (most recent call last):
  File "C:\Users\Endeavour\Desktop\tushare-0.6.8\setup.py", line 4, in <module>
    import tushare
  File "C:\Users\Endeavour\Desktop\tushare-0.6.8\tushare\__init__.py", line 6, in <module>
    from tushare.stock.trading import (get_hist_data, get_tick_data,
  File "C:\Users\Endeavour\Desktop\tushare-0.6.8\tushare\stock\trading.py", line 13, in <module>
    import lxml.html
ModuleNotFoundError: No module named 'lxml'

I have installed python 2.7 and 3.0 on Windows 10, worked on IDLE, no IDE, how can I fix it?

Then I installed lxml:

C:\WINDOWS\system32>pip install lxml

error:

  ** make sure the development packages of libxml2 and libxslt are installed **
  Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?

I could not use pip to install libxml2 and libxslt.

C:\WINDOWS\system32>pip install libxml2
Collecting libxml2
  Could not find a version that satisfies the requirement libxml2 (from versions: )
No matching distribution found for libxml2

C:\WINDOWS\system32>pip install libxslt
Collecting libxslt
  Could not find a version that satisfies the requirement libxslt (from versions: )
No matching distribution found for libxslt

What could I do next?

Have you tried installing lxml ? It seems that all the tracebacks point to not having a module called lxml . Try typing into your terminal prompt: pip install lxml . lxml installs perfectly for me. EDIT:

Looks like libxml2 is not available in pip. I found another stackoverflow question . It seems like they are having the same problems you are. The best part is: if you follow the prebuilt binaries link (which I have conveniently linked here for you), there are downloads for lxml with libxml2 and libsxlt bundled in!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM