Visual Studio 2019 with C++ 已经安装但是CMake找不到

Visual Studio 2019 with C++ has been installed but CMake can't find it

Visual Studio2019 已经安装在我的windows。我已经用它编写了 c++ 代码,编译器没有任何问题。 编译器 cl.exe 存在于此目录中:

C:\Program Files (x86)\Microsoft Visual Studio19\Community\VC\Tools\MSVC.28.29333\bin\Hostx64\x64

想用pip安装dlib时,CMake编译不了

pip install dlib                                                                                               ─╯
Collecting dlib
  Using cached dlib-19.22.1.tar.gz (7.4 MB)
Building wheels for collected packages: dlib
  Building wheel for dlib (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'D:\Anaconda\anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\ali entezari\AppData\Local\Temp\pip-install-y4nrjyij\dlib_9dee571796eb4938989dad25a6107bfa\setup.py'"'"'; __file__='"'"'C:\Users\ali entezari\AppData\Local\Temp\pip-install-y4nrjyij\dlib_9dee571796eb4938989dad25a6107bfa\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\ali entezari\AppData\Local\Temp\pip-wheel-cc19gyz4'
       cwd: C:\Users\ali entezari\AppData\Local\Temp\pip-install-y4nrjyij\dlib_9dee571796eb4938989dad25a6107bfa\
  Complete output (58 lines):
  running bdist_wheel
  running build
  running build_py
  package init file 'tools\python\dlib\__init__.py' not found (or not a regular file)
  running build_ext
  Building extension for Python 3.8.3 (default, Jul  2 2020, 17:30:36) [MSC v.1916 64 bit (AMD64)]
  Invoking CMake setup: 'cmake C:\Users\ali entezari\AppData\Local\Temp\pip-install-y4nrjyij\dlib_9dee571796eb4938989dad25a6107bfa\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\ali entezari\AppData\Local\Temp\pip-install-y4nrjyij\dlib_9dee571796eb4938989dad25a6107bfa\build\lib.win-amd64-3.8 -DPYTHON_EXECUTABLE=D:\Anaconda\anaconda3\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\ali entezari\AppData\Local\Temp\pip-install-y4nrjyij\dlib_9dee571796eb4938989dad25a6107bfa\build\lib.win-amd64-3.8 -A x64'
  -- Building for: NMake Makefiles
  CMake Error at CMakeLists.txt:5 (message):



    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


    You must use Visual Studio to build a python extension on windows.  If you
    are getting this error it means you have not installed Visual C++.  Note
    that there are many flavors of Visual Studio, like Visual Studio for C#
    development.  You need to install Visual Studio for C++.


    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!




  -- Configuring incomplete, errors occurred!
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\ali entezari\AppData\Local\Temp\pip-install-y4nrjyij\dlib_9dee571796eb4938989dad25a6107bfa\setup.py", line 222, in <module>
      setup(
    File "D:\Anaconda\anaconda3\lib\site-packages\setuptools\__init__.py", line 153, in setup
      return distutils.core.setup(**attrs)
    File "D:\Anaconda\anaconda3\lib\distutils\core.py", line 148, in setup
      dist.run_commands()
    File "D:\Anaconda\anaconda3\lib\distutils\dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "D:\Anaconda\anaconda3\lib\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "D:\Anaconda\anaconda3\lib\site-packages\wheel\bdist_wheel.py", line 299, in run
      self.run_command('build')
    File "D:\Anaconda\anaconda3\lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "D:\Anaconda\anaconda3\lib\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "D:\Anaconda\anaconda3\lib\distutils\command\build.py", line 135, in run
      self.run_command(cmd_name)
    File "D:\Anaconda\anaconda3\lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "D:\Anaconda\anaconda3\lib\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "C:\Users\ali entezari\AppData\Local\Temp\pip-install-y4nrjyij\dlib_9dee571796eb4938989dad25a6107bfa\setup.py", line 134, in run
      self.build_extension(ext)
    File "C:\Users\ali entezari\AppData\Local\Temp\pip-install-y4nrjyij\dlib_9dee571796eb4938989dad25a6107bfa\setup.py", line 171, in build_extension
      subprocess.check_call(cmake_setup, cwd=build_folder)
    File "D:\Anaconda\anaconda3\lib\subprocess.py", line 364, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['cmake', 'C:\Users\ali entezari\AppData\Local\Temp\pip-install-y4nrjyij\dlib_9dee571796eb4938989dad25a6107bfa\tools\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\ali entezari\AppData\Local\Temp\pip-install-y4nrjyij\dlib_9dee571796eb4938989dad25a6107bfa\build\lib.win-amd64-3.8', '-DPYTHON_EXECUTABLE=D:\Anaconda\anaconda3\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\ali entezari\AppData\Local\Temp\pip-install-y4nrjyij\dlib_9dee571796eb4938989dad25a6107bfa\build\lib.win-amd64-3.8', '-A', 'x64']' returned non-zero exit status 1.
  ----------------------------------------
  ERROR: Failed building wheel for dlib
  Running setup.py clean for dlib
Failed to build dlib

我检查了我的环境变量路径; VS2019INSTALLDIR 在那里。

VS2019INSTALLDIR C:\Program Files (x86)\Microsoft Visual Studio19\Community

我之前在编译Mozilla Firefox的时候遇到过这个问题,一直没能解决。如果有人可以帮助我摆脱这个问题,我将不胜感激。 对不起英语,我不是母语:)。

我遇到了同样的问题。这可能与您安装的插件和扩展有关。直到我重新安装 Visual Studio,我的问题才得到解决。尝试重新安装。