问题
我这里是windows上使用出现的问题:
代码中使用了 from bs4 import BeautifulSoup
pip install BeautifulSoup
pip install BeautifulSoup4
pip install bs4
分析
使用 python3.7
:
pip install bs4
后 Python37\Lib\site-packages
文件夹下只有 bs4-0.0.1-py3.7.egg-info
,没有 bs4
文件夹(安装过程中会有,但是安装完成后被删除了)。- 会同时安装
BeautifulSoup4
,相当于执行 pip install BeautifulSoup4
,生成了 beautifulsoup4-4.12.0.dist-info
文件夹,没有 BeautifulSoup4
文件夹。
使用 python3.8
:
pip install bs4
后 Python38\Lib\site-packages
文件夹下只有 bs4-0.0.1-py3.8.egg-info
,没有 bs4
文件夹(安装过程中会有,但是安装完成后被删除了)。- 会同时安装
BeautifulSoup4
,相当于执行 pip install BeautifulSoup4
,生成了 beautifulsoup4-4.12.0.dist-info
文件夹,没有 BeautifulSoup4
文件夹。
使用 python3.9
:
pip install bs4
后生成 bs4
、bs4-0.0.1-py3.9.egg-info
、beautifulsoup4-4.12.0.dist-info
python3.7、python3.8 为什么无法安装暂不清楚原因,不知道是不是不支持了。
至于众多文章提到的使用 pycharm
安装bs4就成功了,我尝试后仍然与上述分析结果一致,python3.7、python3.8 无法使用。
解决
- 安装
python3.9
,windows版本下载地址、python-3.9.13.exe,python-3.9.13-amd64.exe 【下载慢的可以用迅雷下载】 - 环境变量添加 安装路径
xxx\Python39\
、xxx\Python39\Scripts
- 变量上移到其他版本python的上面(变量会优先使用上面的)
- 再次运行就不会报错了
其他问题
python3.9 的 pip 无法使用:
> pip -version
Fatal error in launcher: Unable to create process using '"d:\professional_software\python39\python.exe" "D:\Professional_Software\Python\Python39\Scripts\pip.exe" --version': ???????????
python -m ensurepip --upgrade
解决:
先删掉 D:\Professional_Software\Python\Python39\Scripts\pip.exe
,再执行:
python -m pip install -U pip
验证pip是否可使用:
pip --version
pip list
“Fatal error in launcher: Unable to create process using”解决办法
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)