背景
windows系统安装PyCharm和python(3.12版本),配置python环境变量。
PyCharm引入chromedriver,PyCharm使用pip install selenium下载selenium。
报错信息
安装selenium报错信息:
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [24 lines of output]
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "C:\Users\Anna\AppData\Local\Temp\pip-install-3j1kwnjl\cffi_4cd60f11518743e2b17a64647b3a4b12\setup.py", line 126, in <module>
if sys.platform == "win32" and uses_msvc():
^^^^^^^^^^^
File "C:\Users\Anna\AppData\Local\Temp\pip-install-3j1kwnjl\cffi_4cd60f11518743e2b17a64647b3a4b12\setup.py", line 105, in uses_msvc
return config.try_compile('#ifndef _MSC_VER\n#error "not MSVC"\n#endif')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\xx\code\PycharmProjects\venv\Lib\site-packages\setuptools\_distutils\command\config.py", line 223, in try_compile
self._compile(body, headers, include_dirs, lang)
File "C:\xx\code\PycharmProjects\venv\Lib\site-packages\setuptools\_distutils\command\config.py", line 128, in _compile
self.compiler.compile([src], include_dirs=include_dirs)
File "C:\xx\code\PycharmProjects\venv\Lib\site-packages\setuptools\_distutils\_msvccompiler.py", line 343, in compile
self.initialize()
File "C:\xx\code\PycharmProjects\venv\Lib\site-packages\setuptools\_distutils\_msvccompiler.py", line 253, in initialize
vc_env = _get_vc_env(plat_spec)
^^^^^^^^^^^^^^^^^^^^^^
File "C:\xx\code\PycharmProjects\venv\Lib\site-packages\setuptools\msvc.py", line 214, in msvc14_get_vc_env
return _msvc14_get_vc_env(plat_spec)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\xx\code\PycharmProjects\venv\Lib\site-packages\setuptools\msvc.py", line 168, in _msvc14_get_vc_env
raise distutils.errors.DistutilsPlatformError(
distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
解决过程
度娘上看了各种类似报错的处理方法,跟着折腾了一遍,花了一整天都没搞定,郁闷了。
第二天继续处理,看到上文python版本标红,敏感的小伙伴可能发现为什么要标红了。因为这特么就是我忙碌了一整天一无所获,搞不定selenium安装的罪魁祸首!!!
再搜到一篇文章提到了python版本的问题,另想起以前一起写代码的小伙伴们都说过,python版本过高可能会有问题的。果断不再从报错信息入手,换个思路,直接给python版本降级。。卸载掉3.12版本的python,重新安装3.9版本的。
python官方下载是真的慢,用国内镜像,python下载地址:CNPM Binaries Mirror
pycharm里继续pip install selenum,重启pycharm,搞定了!!!!
selenium这不就有了么~~~~文章来源:https://www.toymoban.com/news/detail-696299.html
文章来源地址https://www.toymoban.com/news/detail-696299.html
到了这里,关于【selenium】pip install selenuim失败问题解决的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!