我想在非特权环境中使用PlayWriter for Python.

在嵌入式python环境中运行pip install pytest-playwright之后,我得到以下错误:

Building wheels for collected packages: greenlet
  Building wheel for greenlet (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [90 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-312
      creating build\lib.win-amd64-cpython-312\greenlet
      copying src\greenlet\__init__.py -> build\lib.win-amd64-cpython-312\greenlet
      creating build\lib.win-amd64-cpython-312\greenlet\platform
      copying src\greenlet\platform\__init__.py -> build\lib.win-amd64-cpython-312\greenlet\platform
      creating build\lib.win-amd64-cpython-312\greenlet\tests
      copying src\greenlet\tests\leakcheck.py -> build\lib.win-amd64-cpython-312\greenlet\tests
      copying src\greenlet\tests\test_contextvars.py -> build\lib.win-amd64-cpython-312\greenlet\tests
      copying src\greenlet\tests\test_cpp.py -> build\lib.win-amd64-cpython-312\greenlet\tests
      copying src\greenlet\tests\test_extension_interface.py -> build\lib.win-amd64-cpython-312\greenlet\tests
      copying src\greenlet\tests\test_gc.py -> build\lib.win-amd64-cpython-312\greenlet\tests
      copying src\greenlet\tests\test_generator.py -> build\lib.win-amd64-cpython-312\greenlet\tests
      copying src\greenlet\tests\test_generator_nested.py -> build\lib.win-amd64-cpython-312\greenlet\tests
      copying src\greenlet\tests\test_greenlet.py -> build\lib.win-amd64-cpython-312\greenlet\tests
      copying src\greenlet\tests\test_greenlet_trash.py -> build\lib.win-amd64-cpython-312\greenlet\tests
      copying src\greenlet\tests\test_leaks.py -> build\lib.win-amd64-cpython-312\greenlet\tests
      copying src\greenlet\tests\test_stack_saved.py -> build\lib.win-amd64-cpython-312\greenlet\tests
      copying src\greenlet\tests\test_throw.py -> build\lib.win-amd64-cpython-312\greenlet\tests
      copying src\greenlet\tests\test_tracing.py -> build\lib.win-amd64-cpython-312\greenlet\tests
      copying src\greenlet\tests\test_version.py -> build\lib.win-amd64-cpython-312\greenlet\tests
      copying src\greenlet\tests\test_weakref.py -> build\lib.win-amd64-cpython-312\greenlet\tests
      copying src\greenlet\tests\__init__.py -> build\lib.win-amd64-cpython-312\greenlet\tests
      running egg_info
      writing src\greenlet.egg-info\PKG-INFO
      writing dependency_links to src\greenlet.egg-info\dependency_links.txt
      writing requirements to src\greenlet.egg-info\requires.txt
      writing top-level names to src\greenlet.egg-info\top_level.txt
      reading manifest file 'src\greenlet.egg-info\SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      warning: no previously-included files found matching 'benchmarks\*.json'
      no previously-included directories found matching 'docs\_build'
      warning: no files found matching '*.py' under directory 'appveyor'
      warning: no previously-included files matching '*.pyc' found anywhere in distribution
      warning: no previously-included files matching '*.pyd' found anywhere in distribution
      warning: no previously-included files matching '*.so' found anywhere in distribution
      warning: no previously-included files matching '.coverage' found anywhere in distribution
      adding license file 'LICENSE'
      adding license file 'LICENSE.PSF'
      adding license file 'AUTHORS'
      writing manifest file 'src\greenlet.egg-info\SOURCES.txt'
      copying src\greenlet\greenlet.cpp -> build\lib.win-amd64-cpython-312\greenlet
      copying src\greenlet\greenlet.h -> build\lib.win-amd64-cpython-312\greenlet
      copying src\greenlet\greenlet_allocator.hpp -> build\lib.win-amd64-cpython-312\greenlet
      copying src\greenlet\greenlet_compiler_compat.hpp -> build\lib.win-amd64-cpython-312\greenlet
      copying src\greenlet\greenlet_cpython_compat.hpp -> build\lib.win-amd64-cpython-312\greenlet
      copying src\greenlet\greenlet_exceptions.hpp -> build\lib.win-amd64-cpython-312\greenlet
      copying src\greenlet\greenlet_greenlet.hpp -> build\lib.win-amd64-cpython-312\greenlet
      copying src\greenlet\greenlet_internal.hpp -> build\lib.win-amd64-cpython-312\greenlet
      copying src\greenlet\greenlet_refs.hpp -> build\lib.win-amd64-cpython-312\greenlet
      copying src\greenlet\greenlet_slp_switch.hpp -> build\lib.win-amd64-cpython-312\greenlet
      copying src\greenlet\greenlet_thread_state.hpp -> build\lib.win-amd64-cpython-312\greenlet
      copying src\greenlet\greenlet_thread_state_dict_cleanup.hpp -> build\lib.win-amd64-cpython-312\greenlet
      copying src\greenlet\greenlet_thread_support.hpp -> build\lib.win-amd64-cpython-312\greenlet
      copying src\greenlet\slp_platformselect.h -> build\lib.win-amd64-cpython-312\greenlet
      copying src\greenlet\platform\setup_switch_x64_masm.cmd -> build\lib.win-amd64-cpython-312\greenlet\platform
      copying src\greenlet\platform\switch_aarch64_gcc.h -> build\lib.win-amd64-cpython-312\greenlet\platform
      copying src\greenlet\platform\switch_alpha_unix.h -> build\lib.win-amd64-cpython-312\greenlet\platform
      copying src\greenlet\platform\switch_amd64_unix.h -> build\lib.win-amd64-cpython-312\greenlet\platform
      copying src\greenlet\platform\switch_arm32_gcc.h -> build\lib.win-amd64-cpython-312\greenlet\platform
      copying src\greenlet\platform\switch_arm32_ios.h -> build\lib.win-amd64-cpython-312\greenlet\platform
      copying src\greenlet\platform\switch_arm64_masm.asm -> build\lib.win-amd64-cpython-312\greenlet\platform
      copying src\greenlet\platform\switch_arm64_masm.obj -> build\lib.win-amd64-cpython-312\greenlet\platform
      copying src\greenlet\platform\switch_arm64_msvc.h -> build\lib.win-amd64-cpython-312\greenlet\platform
      copying src\greenlet\platform\switch_csky_gcc.h -> build\lib.win-amd64-cpython-312\greenlet\platform
      copying src\greenlet\platform\switch_m68k_gcc.h -> build\lib.win-amd64-cpython-312\greenlet\platform
      copying src\greenlet\platform\switch_mips_unix.h -> build\lib.win-amd64-cpython-312\greenlet\platform
      copying src\greenlet\platform\switch_ppc64_aix.h -> build\lib.win-amd64-cpython-312\greenlet\platform
      copying src\greenlet\platform\switch_ppc64_linux.h -> build\lib.win-amd64-cpython-312\greenlet\platform
      copying src\greenlet\platform\switch_ppc_aix.h -> build\lib.win-amd64-cpython-312\greenlet\platform
      copying src\greenlet\platform\switch_ppc_linux.h -> build\lib.win-amd64-cpython-312\greenlet\platform
      copying src\greenlet\platform\switch_ppc_macosx.h -> build\lib.win-amd64-cpython-312\greenlet\platform
      copying src\greenlet\platform\switch_ppc_unix.h -> build\lib.win-amd64-cpython-312\greenlet\platform
      copying src\greenlet\platform\switch_riscv_unix.h -> build\lib.win-amd64-cpython-312\greenlet\platform
      copying src\greenlet\platform\switch_s390_unix.h -> build\lib.win-amd64-cpython-312\greenlet\platform
      copying src\greenlet\platform\switch_sparc_sun_gcc.h -> build\lib.win-amd64-cpython-312\greenlet\platform
      copying src\greenlet\platform\switch_x32_unix.h -> build\lib.win-amd64-cpython-312\greenlet\platform
      copying src\greenlet\platform\switch_x64_masm.asm -> build\lib.win-amd64-cpython-312\greenlet\platform
      copying src\greenlet\platform\switch_x64_masm.obj -> build\lib.win-amd64-cpython-312\greenlet\platform
      copying src\greenlet\platform\switch_x64_msvc.h -> build\lib.win-amd64-cpython-312\greenlet\platform
      copying src\greenlet\platform\switch_x86_msvc.h -> build\lib.win-amd64-cpython-312\greenlet\platform
      copying src\greenlet\platform\switch_x86_unix.h -> build\lib.win-amd64-cpython-312\greenlet\platform
      copying src\greenlet\tests\_test_extension.c -> build\lib.win-amd64-cpython-312\greenlet\tests
      copying src\greenlet\tests\_test_extension_cpp.cpp -> build\lib.win-amd64-cpython-312\greenlet\tests
      running build_ext
      building 'greenlet._greenlet' extension
      error: 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: Failed building wheel for greenlet
  Running setup.py clean for greenlet
Failed to build greenlet
ERROR: Could not build wheels for greenlet, which is required to install pyproject.toml-based projects

错误消息显示"需要Microsoft Visual C++14.0或更高版本.",但我被禁止安装Microsoft Visual C++.

有没有可能使用MinGW-W64而不是Microsoft Visual C++来安装pytest-playwright?

我try 了以下三种不同的方法,但未能成功安装pytest-playwright.

  • 添加PYTHONPATH\Lib\distutils\distutils.cfg并运行pip install pytest-playwright.
[build]
compiler=mingw32

[build_ext]
compiler=mingw32
  • 使用选项--global-option--compilerGitHub下载.zip文件进行安装.
> pip install --global-option build_ext --global-option --compiler=mingw32 playwright-pytest-0.4.3.zip
  • 与.Whl文件一起安装
> pip install greenlet-3.0.0-cp312-cp312-win_amd64.whl
> pip install pytest_playwright-0.4.3-py3-none-any.whl

我的环境是这样的:

  • 操作系统:Windows 10专业版22H2 64位
  • Python:3.12.0可嵌入包(64位)
  • PIP:23.2.1(使用get-pip.py安装)
  • MinGW-W64:13.2.0由MinGW-Builds项目构建(x86_64-13.2.0-release-posix-seh-ucrt-rt_v11-rev0.7z)

推荐答案

我通过将Python从版本3.12.0降级到版本3.11.6解决了这个问题.

感谢所有对我的问题发表 comments 的人. 我会将这个问题标记为已解决.

Python相关问答推荐

Twilio:CallInstance对象没有来自_的属性'

在应用循环中间保存pandas DataFrame

使用pandas、matplotlib和Yearbox绘制时显示错误的年份

如何使用Google Gemini API为单个提示生成多个响应?

Class_weight参数不影响RandomForestClassifier不平衡数据集中的结果

使用新的类型语法正确注释ParamSecdecorator (3.12)

如何比较numPy数组中的两个图像以获取它们不同的像素

为什么带有dropna=False的groupby会阻止后续的MultiIndex.dropna()工作?

根据二元组列表在pandas中创建新列

Polars:用氨纶的其他部分替换氨纶的部分

使用setuptools pyproject.toml和自定义目录树构建PyPi包

Pandas—在数据透视表中占总数的百分比

改进大型数据集的框架性能

未知依赖项pin—1阻止conda安装""

从Windows Python脚本在WSL上运行Linux应用程序

python—telegraph—bot send_voice发送空文件

获取PANDA GROUP BY转换中的组的名称

如何将泛型类类型与函数返回类型结合使用?

python的文件. truncate()意外地没有截断'

当我定义一个继承的类时,我可以避免使用`metaclass=`吗?