Where is BeautifulSoup4 hiding?

后端 未结 3 720
梦谈多话
梦谈多话 2020-12-05 14:52

I did sudo pip install BeautifulSoup4 and got an awfully optimistic response:

Downloading/unpacking beautifulsoup4
  Running setup.py egg_info f         


        
相关标签:
3条回答
  • 2020-12-05 15:34

    Try import bs4. It's unfortunate there's no correspondence between PyPI package name and import name. After that the class names are the same as before eg. soup = bs4.BeautifulSoup(doc) will work.

    If that still doesn't work, try pip install again and note the path to the package install. Then in your python console run import sys and print sys.path to make sure that the path is there.

    You might need to explicitly specify pip-2.7 or switch to easy_install (or easy_install-2.7)

    0 讨论(0)
  • 2020-12-05 15:34

    After trying the easy_install and pip if things dont work then download the tz package from the package website untar it in a folder. Now open cmd window and go to the directory where you unzip the tz and run the command 'python setup.py install' IT should work

    0 讨论(0)
  • 2020-12-05 15:40

    Try this: from bs4 import BeautifulSoup

    0 讨论(0)
提交回复
热议问题