Installing BeautifulSoup4 via pip produces an import error for Python 3.5
我正在尝试为python 3.5安装beautifulsoup4,但是,当我调用"import bs4"在python 3.5.2 shell中进行测试时,我收到以下错误:
Traceback (most recent call last):
File"", line 1, in
import bs4
File"C:\Users\Dan\AppData\Local\Programs\Python\Python35\lib\bs4__init__.py", line 53
'You are trying to run the Python 2 version of Beautiful Soup under Python 3. This will not work.'<>'You need to convert the code, either by installing it (python setup.py install ) or by running 2to3 (2to3 -w bs4 ).'
^
SyntaxError: invalid syntax
我按照下面的路径运行pip以最初安装beatifulsoup4,我在公司代理周围安装的命令是:$pip install--proxy=proxy.com beautifulsoup4
C:\Users\Dan\AppData\Local\Programs\Python\Python35\Scripts
我以前在这台计算机上安装过python2.7,但是我在安装3.5时卸载了它。如果我没有正确卸载python 2.7,那么pip是否会未能安装并转换bs4 for 3.5?我还尝试了与请求模块相同的步骤。我尝试使用python shell推荐的命令进行转换,但尝试使用"2to3"也失败了。感谢您的帮助。
"这是python2版本安装到你的python3
如果你认为现在的
1 | pip install bs4 --ignore-installed |