pythonpython-3.xpippython.netpywebview

pywebview installing Error Python windows 10 (Python 3.10.5) "pip install pywebview"


On executing pip install pywebview i encountered this error.I want to view a webpage in python without using external browser.

C:\Users\anik4\Desktop\New folder\Website Blocker> pip install pywebview       
Collecting pywebview
  Using cached pywebview-3.6.3-py3-none-any.whl (351 kB)
Collecting pythonnet
  Using cached pythonnet-2.5.2.tar.gz (1.9 MB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: proxy-tools in c:\users\anik4\appdata\local\programs\python\python310\lib\site-packages (from pywebview) (0.1.0)        
Requirement already satisfied: pycparser in c:\users\anik4\appdata\local\programs\python\python310\lib\site-packages (from pythonnet->pywebview) (2.21)
Building wheels for collected packages: pythonnet
  Building wheel for pythonnet (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [104 lines of output]
      running bdist_wheel
      running build
      running build_ext
      Checking for updates from https://www.nuget.org/api/v2/.
      Currently running NuGet.exe 4.1.0.
      Updating NuGet.exe to 6.3.0.
      Update successful.
      Cannot find the specified version of msbuild: '14'
      MSBuild auto-detection: using msbuild version '4.0' from 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319'.
      C:\Users\anik4\AppData\Local\Temp\NuGetScratch\vcolbnzs.pl2.nugetrestore.targets(539,20): error MSB4086: A numeric comparison was attempted on "$(MSBuildAssemblyVersion)" that 
evaluates to "" instead of a number, in condition "'$(MSBuildAssemblyVersion)' < '15.0'". [C:\Users\anik4\AppData\Local\Temp\pip-install-d8wxkf3e\pythonnet_dd7fee9480cf4e57afd5dfe60886bc32\src\runtime\Python.Runtime.csproj]
      C:\Users\anik4\AppData\Local\Temp\NuGetScratch\vcolbnzs.pl2.nugetrestore.targets(539,20): error MSB4086: A numeric comparison was attempted on "$(MSBuildAssemblyVersion)" that 
evaluates to "" instead of a number, in condition "'$(MSBuildAssemblyVersion)' < '15.0'". [C:\Users\anik4\AppData\Local\Temp\pip-install-d8wxkf3e\pythonnet_dd7fee9480cf4e57afd5dfe60886bc32\src\testing\Python.Test.csproj]
      C:\Users\anik4\AppData\Local\Temp\NuGetScratch\vcolbnzs.pl2.nugetrestore.targets(539,20): error MSB4086: A numeric comparison was attempted on "$(MSBuildAssemblyVersion)" that 
evaluates to "" instead of a number, in condition "'$(MSBuildAssemblyVersion)' < '15.0'". [C:\Users\anik4\AppData\Local\Temp\pip-install-d8wxkf3e\pythonnet_dd7fee9480cf4e57afd5dfe60886bc32\src\embed_tests\Python.EmbeddingTest.csproj]
      C:\Users\anik4\AppData\Local\Temp\NuGetScratch\vcolbnzs.pl2.nugetrestore.targets(539,20): error MSB4086: A numeric comparison was attempted on "$(MSBuildAssemblyVersion)" that 
evaluates to "" instead of a number, in condition "'$(MSBuildAssemblyVersion)' < '15.0'". [C:\Users\anik4\AppData\Local\Temp\pip-install-d8wxkf3e\pythonnet_dd7fee9480cf4e57afd5dfe60886bc32\src\console\Console.csproj]
      C:\Users\anik4\AppData\Local\Temp\NuGetScratch\vcolbnzs.pl2.nugetrestore.targets(539,20): error MSB4086: A numeric comparison was attempted on "$(MSBuildAssemblyVersion)" that 
evaluates to "" instead of a number, in condition "'$(MSBuildAssemblyVersion)' < '15.0'". [C:\Users\anik4\AppData\Local\Temp\pip-install-d8wxkf3e\pythonnet_dd7fee9480cf4e57afd5dfe60886bc32\src\clrmodule\clrmodule.csproj]
     
      WARNING: Error reading msbuild project information, ensure that your input solution or project file is valid. NETCore and UAP projects will be skipped, only packages.config files will be restored.
      Restoring NuGet package UnmanagedExports.1.2.7.
      Restoring NuGet package NUnit.ConsoleRunner.3.11.1.
      Restoring NuGet package System.ValueTuple.4.5.0.
      Restoring NuGet package NUnit.3.12.0.
      Adding package 'System.ValueTuple.4.5.0' to folder 'C:\Users\anik4\AppData\Local\Temp\pip-install-d8wxkf3e\pythonnet_dd7fee9480cf4e57afd5dfe60886bc32\packages'
      Adding package 'NUnit.3.12.0' to folder 'C:\Users\anik4\AppData\Local\Temp\pip-install-d8wxkf3e\pythonnet_dd7fee9480cf4e57afd5dfe60886bc32\packages'
      Adding package 'UnmanagedExports.1.2.7' to folder 'C:\Users\anik4\AppData\Local\Temp\pip-install-d8wxkf3e\pythonnet_dd7fee9480cf4e57afd5dfe60886bc32\packages'
      Adding package 'NUnit.ConsoleRunner.3.11.1' to folder 'C:\Users\anik4\AppData\Local\Temp\pip-install-d8wxkf3e\pythonnet_dd7fee9480cf4e57afd5dfe60886bc32\packages'
      Added package 'UnmanagedExports.1.2.7' to folder 'C:\Users\anik4\AppData\Local\Temp\pip-install-d8wxkf3e\pythonnet_dd7fee9480cf4e57afd5dfe60886bc32\packages'
      Added package 'NUnit.ConsoleRunner.3.11.1' to folder 'C:\Users\anik4\AppData\Local\Temp\pip-install-d8wxkf3e\pythonnet_dd7fee9480cf4e57afd5dfe60886bc32\packages'
      Added package 'System.ValueTuple.4.5.0' to folder 'C:\Users\anik4\AppData\Local\Temp\pip-install-d8wxkf3e\pythonnet_dd7fee9480cf4e57afd5dfe60886bc32\packages'
      Added package 'NUnit.3.12.0' to folder 'C:\Users\anik4\AppData\Local\Temp\pip-install-d8wxkf3e\pythonnet_dd7fee9480cf4e57afd5dfe60886bc32\packages'
     
      NuGet Config files used:
          C:\Users\anik4\AppData\Roaming\NuGet\NuGet.Config
     
      Feeds used:
          C:\Users\anik4\.nuget\packages\
          https://api.nuget.org/v3/index.json
     
      Installed:
          4 package(s) to packages.config projects
      Traceback (most recent call last):
        File "C:\Users\anik4\AppData\Local\Temp\pip-install-d8wxkf3e\pythonnet_dd7fee9480cf4e57afd5dfe60886bc32\tools\geninterop\geninterop.py", line 396, in <module>
          sys.exit(main())
        File "C:\Users\anik4\AppData\Local\Temp\pip-install-d8wxkf3e\pythonnet_dd7fee9480cf4e57afd5dfe60886bc32\tools\geninterop\geninterop.py", line 357, in main
          python_h = preprocess_python_headers()
        File "C:\Users\anik4\AppData\Local\Temp\pip-install-d8wxkf3e\pythonnet_dd7fee9480cf4e57afd5dfe60886bc32\tools\geninterop\geninterop.py", line 238, in preprocess_python_headers
          for line in _check_output(cmd).splitlines():
        File "C:\Users\anik4\AppData\Local\Temp\pip-install-d8wxkf3e\pythonnet_dd7fee9480cf4e57afd5dfe60886bc32\tools\geninterop\geninterop.py", line 46, in _check_output
          output = subprocess.check_output(*args, **kwargs)
        File "C:\Users\anik4\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 420, in check_output
          return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
        File "C:\Users\anik4\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 501, in run
          with Popen(*popenargs, **kwargs) as process:
        File "C:\Users\anik4\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 969, in __init__
          self._execute_child(args, executable, preexec_fn, close_fds,
        File "C:\Users\anik4\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1438, in _execute_child
          hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
      FileNotFoundError: [WinError 2] The system cannot find the file specified
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\anik4\AppData\Local\Temp\pip-install-d8wxkf3e\pythonnet_dd7fee9480cf4e57afd5dfe60886bc32\setup.py", line 630, in <module>
          setup(
        File "C:\Users\anik4\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\__init__.py", line 87, in setup
          return distutils.core.setup(**attrs)
        File "C:\Users\anik4\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\core.py", line 177, in setup
          return run_commands(dist)
        File "C:\Users\anik4\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\core.py", line 193, in run_commands
          dist.run_commands()
        File "C:\Users\anik4\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\dist.py", line 968, in run_commands
          self.run_command(cmd)
        File "C:\Users\anik4\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\dist.py", line 1229, in run_command
          super().run_command(command)
        File "C:\Users\anik4\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\dist.py", line 987, in run_command
          cmd_obj.run()
        File "C:\Users\anik4\AppData\Local\Temp\pip-install-d8wxkf3e\pythonnet_dd7fee9480cf4e57afd5dfe60886bc32\setup.py", line 612, in run
          return bdist_wheel.bdist_wheel.run(self)
        File "C:\Users\anik4\AppData\Local\Programs\Python\Python310\lib\site-packages\wheel\bdist_wheel.py", line 299, in run
          self.run_command('build')
        File "C:\Users\anik4\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\cmd.py", line 317, in run_command
          self.distribution.run_command(command)
        File "C:\Users\anik4\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\dist.py", line 1229, in run_command
          super().run_command(command)
        File "C:\Users\anik4\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\dist.py", line 987, in run_command
          cmd_obj.run()
        File "C:\Users\anik4\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\command\build.py", line 24, in run
          super().run()
        File "C:\Users\anik4\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\command\build.py", line 131, in run
          self.run_command(cmd_name)
        File "C:\Users\anik4\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\cmd.py", line 317, in run_command
          self.distribution.run_command(command)
        File "C:\Users\anik4\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\dist.py", line 1229, in run_command
          super().run_command(command)
        File "C:\Users\anik4\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\dist.py", line 987, in run_command
          cmd_obj.run()
        File "C:\Users\anik4\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\command\build_ext.py", line 339, in run
          self.build_extensions()
        File "C:\Users\anik4\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\command\build_ext.py", line 459, in build_extensions
          self._build_extensions_serial()
        File "C:\Users\anik4\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\_distutils\command\build_ext.py", line 485, in _build_extensions_serial
          self.build_extension(ext)
        File "C:\Users\anik4\AppData\Local\Temp\pip-install-d8wxkf3e\pythonnet_dd7fee9480cf4e57afd5dfe60886bc32\setup.py", line 302, in build_extension
          subprocess.check_call([sys.executable, geninterop, interop_file])
        File "C:\Users\anik4\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 369, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['C:\\Users\\anik4\\AppData\\Local\\Programs\\Python\\Python310\\python.exe', 'tools\\geninterop\\geninterop.py', 'src\\runtime\\interop310.cs']' returned non-zero exit status 1.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pythonnet
  Running setup.py clean for pythonnet
Failed to build pythonnet
Installing collected packages: pythonnet, pywebview
  Running setup.py install for pythonnet ... error
  error: subprocess-exited-with-error

  × Running setup.py install for pythonnet did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]
      usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
         or: setup.py --help [cmd1 cmd2 ...]
         or: setup.py --help-commands
         or: setup.py cmd --help
     
      error: option --single-version-externally-managed not recognized
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> pythonnet

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

How do i counter it?,Python3.8, windows 10 ,computer-user:sindhuthe below text is just to pass the stackoverflow error the error seems eror but not error or a error like the error which is an error but acts and walks and quacks like an error but never an error.


Solution

  • PyWebView has PythonNET as a dependency, and that's the one causing problems.

    You're using Python 3.10.
    First, you should install PythonNET as described in [SO]: How to fix error during pythonnet installation (@CristiFati's answer) (where I moved most of the original version of this answer), and only then install PyWebView (when searching for dependencies it will see it as already installed and will no longer try to install it).

    Since PyWebView doesn't require a specific PythonNET version, this should work (in theory, if they kept API (interface) backward compatible enough).

    Note that everything related to PythonNet could also apply to other dependencies (recursively).