情况:
-
安装了Python3
-
已安装PyCharm
-
将PIP更新为v9
-
将setuptools更新为v32
-
已安装BeautifulSoup4
在Python3中,当我运行 from bs4 import beautifulsoup
时,我回复了:
回溯(最近一次调用最后一次):文件“”,第1行,在文件“/Users/stevendiffey/.Trash/3.6/beautifulsoup4-4.5.1/bs4/init.py”,第53行'你正试图运行Python 3下的Beautiful Soup的Python 2版本 . 这不起作用 . '<>'您需要通过安装它(python setup.py install)或运行2to3(2to3 -w bs4)来转换代码 .
我是Python的新手,已经搜索过一个解决方案,但无济于事 .
如果有人可以提供帮助,那将是圣诞节的待遇:)
2 回答
你的错误应该是
/Python3.6/Lib/site-packages/bs4/init.py 是兼容py2的模块
不
/ Users / stevendiffey / .Trash /3.6/beautifulsoup4-4.5.1/bs4/init.py
确保您正在运行/Python3.6/python.exe
尝试
导入系统
对于sys.path中的i:
确保/Python3.6/Lib/site-packages上游
原来只需要使用正确的帽子并替换:
有: