简体   繁体   中英

Python: ImportError: cannot import name 'BeautifulSoup'

I have always used R and now trying to switch to Python. I'm using Pycharm and found this error when running the following code:

import pandas as pd
from bs4 import BeautifulSoup
example1 = BeautifulSoup(train["review"][0],"lxml")
print (example1.get_text())

When I run it I have:

ImportError: cannot import name 'BeautifulSoup'

But I don't have any problem using the console. The rest of the code works fine both with the Run command/terminal and console.

Thank you for your help

Oh,I think you should check your file name or folder name.If there is a name that is already used in bs4 module,you will got ImportError.

Hope this helps.

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