alireza mousavi
alireza mousavi

Reputation: 31

error in installing dlib library in python 3.10

when install dlip library for face scan in python 3.10 this error hapend oder librarys dont have problem Microsoft Windows [Version 10.0.19043.1348] (c) Microsoft Corporation. All rights reserved.

C:\Users\sooz>pip install dlib Collecting dlib Using cached dlib-19.22.1.tar.gz (7.4 MB) Preparing metadata (setup.py) ... done Using legacy 'setup.py install' for dlib, since package 'wheel' is not installed. Installing collected packages: dlib Running setup.py install for dlib ... error

    ERROR: Command errored out with exit status 1:
 command: 'C:\Users\sooz\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\sooz\\AppData\\Local\\Temp\\pip-install-0jjhxyj3\\dlib_489a4507707a49f6becd53489abedb63\\setup.py'"'"'; __file__='"'"'C:\\Users\\sooz\\AppData\\Local\\Temp\\pip-install-0jjhxyj3\\dlib_489a4507707a49f6becd53489abedb63\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\sooz\AppData\Local\Temp\pip-record-jpp9ywr4\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\sooz\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Include\dlib'
     cwd: C:\Users\sooz\AppData\Local\Temp\pip-install-0jjhxyj3\dlib_489a4507707a49f6becd53489abedb63\
Complete output (323 lines):
running install
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.10.0 (tags/v3.10.0:b494f59, Oct  4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)]
Invoking CMake setup: 'cmake C:\Users\sooz\AppData\Local\Temp\pip-install-0jjhxyj3\dlib_489a4507707a49f6becd53489abedb63\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\sooz\AppData\Local\Temp\pip-install-0jjhxyj3\dlib_489a4507707a49f6becd53489abedb63\build\lib.win-amd64-3.10 -DPYTHON_EXECUTABLE=C:\Users\sooz\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\sooz\AppData\Local\Temp\pip-install-0jjhxyj3\dlib_489a4507707a49f6becd53489abedb63\build\lib.win-amd64-3.10 -A x64'
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19043.
-- The C compiler identification is MSVC 19.30.30705.0
-- The CXX compiler identification is MSVC 19.30.30705.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.30.30705/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.30.30705/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: C:/Users/sooz/AppData/Local/Microsoft/WindowsApps/PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0/python.exe (found version "3.10")
-- Found PythonLibs: C:/Program Files/WindowsApps/PythonSoftwareFoundation.Python.3.10_3.10.240.0_x64__qbz5n2kfra8p0/libs/Python310.lib
-- pybind11 v2.2.4
-- Using CMake version: 3.22.0
-- Compiling dlib version: 19.22.1
-- SSE4 instructions can be executed by the host processor.
-- AVX instructions can be executed by the host processor.
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of void*
-- Check size of void* - done
-- Enabling AVX instructions
-- Searching for BLAS and LAPACK
-- Searching for BLAS and LAPACK
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
CUDA_TOOLKIT_ROOT_DIR not found or specified
-- Could NOT find CUDA (missing: CUDA_TOOLKIT_ROOT_DIR CUDA_NVCC_EXECUTABLE CUDA_INCLUDE_DIRS CUDA_CUDART_LIBRARY) (Required is at least version "7.5")
-- Found CUDA, but CMake was unable to find the cuBLAS libraries that should be part of every basic CUDA install. Your CUDA install is somehow broken or incomplete. Since cuBLAS is required for dlib to use CUDA we won't use CUDA.
-- DID NOT FIND CUDA
-- Disabling CUDA support for dlib.  DLIB WILL NOT USE CUDA
-- C++11 activated.
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/sooz/AppData/Local/Temp/pip-install-0jjhxyj3/dlib_489a4507707a49f6becd53489abedb63/build/temp.win-amd64-3.10/Release
Invoking CMake build: 'cmake --build . --config Release -- /m'
Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(514,5): warning MSB8029: The Intermediate directory or Output directory cannot reside under the Temporary directory as it could lead to issues with incremental build. [C:\Users\sooz\AppData\Local\Temp\pip-install-0jjhxyj3\dlib_489a4507707a49f6becd53489abedb63\build\temp.win-amd64-3.10\Release\ZERO_CHECK.vcxproj]
  Checking Build System
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(514,5): warning MSB8029: The Intermediate directory or Output directory cannot reside under the Temporary directory as it could lead to issues with incremental build. [C:\Users\sooz\AppData\Local\Temp\pip-install-0jjhxyj3\dlib_489a4507707a49f6becd53489abedb63\build\temp.win-amd64-3.10\Release\dlib_build\dlib.vcxproj]
  Building Custom Rule C:/Users/sooz/AppData/Local/Temp/pip-install-0jjhxyj3/dlib_489a4507707a49f6becd53489abedb63/dlib/CMakeLists.txt
  base64_kernel_1.cpp
  bigint_kernel_1.cpp
  bigint_kernel_2.cpp
  bit_stream_kernel_1.cpp
  entropy_decoder_kernel_1.cpp
  entropy_decoder_kernel_2.cpp
  entropy_encoder_kernel_1.cpp
  entropy_encoder_kernel_2.cpp
  md5_kernel_1.cpp
  tokenizer_kernel_1.cpp
  unicode.cpp
  test_for_odr_violations.cpp
  sockets_kernel_1.cpp
  bsp.cpp
  dir_nav_kernel_1.cpp
  dir_nav_kernel_2.cpp
  dir_nav_extensions.cpp
  fonts.cpp
  linker_kernel_1.cpp
  extra_logger_headers.cpp
  logger_kernel_1.cpp
  logger_config_file.cpp
  misc_api_kernel_1.cpp
  misc_api_kernel_2.cpp
  sockets_extensions.cpp
  sockets_kernel_2.cpp
  sockstreambuf.cpp
  sockstreambuf_unbuffered.cpp
  server_kernel.cpp
  server_iostream.cpp
  server_http.cpp
  multithreaded_object_extension.cpp
  threaded_object_extension.cpp
  threads_kernel_1.cpp
  threads_kernel_2.cpp
  threads_kernel_shared.cpp
  thread_pool_extension.cpp
  async.cpp
  timer.cpp
  stack_trace.cpp
  cpu_dlib.cpp
  tensor_tools.cpp
  image_dataset_metadata.cpp
  mnist.cpp
  cifar.cpp
  global_function_search.cpp
  kalman_filter.cpp
  auto.cpp
  widgets.cpp
  drawable.cpp
  canvas_drawing.cpp
  style.cpp
  base_widgets.cpp
  gui_core_kernel_1.cpp
  gui_core_kernel_2.cpp
  png_loader.cpp
  save_png.cpp
  jpeg_loader.cpp
  save_jpeg.cpp
  arm_init.c
  filter_neon_intrinsics.c
  png.c
  pngerror.c
  pngget.c
  pngmem.c
  pngpread.c
  pngread.c
  pngrio.c
  pngrtran.c
  pngrutil.c
  pngset.c
  pngtrans.c
  pngwio.c
  pngwrite.c
  pngwtran.c
  pngwutil.c
  adler32.c
  compress.c
  crc32.c
  deflate.c
  gzclose.c
  gzlib.c
  gzread.c
  gzwrite.c
  infback.c
  inffast.c
  inflate.c
  inftrees.c
C:\Users\sooz\AppData\Local\Temp\pip-install-0jjhxyj3\dlib_489a4507707a49f6becd53489abedb63\dlib\external\zlib\gzread.c(319,17): warning C4267: '=': conversion from 'size_t' to 'unsigned int', possible loss of data [C:\Users\sooz\AppData\Local\Temp\pip-install-0jjhxyj3\dlib_489a4507707a49f6becd53489abedb63\build\temp.win-amd64-3.10\Release\dlib_build\dlib.vcxproj]
C:\Users\sooz\AppData\Local\Temp\pip-install-0jjhxyj3\dlib_489a4507707a49f6becd53489abedb63\dlib\external\zlib\gzread.c(400,18): warning C4267: '=': conversion from 'size_t' to 'unsigned int', possible loss of data [C:\Users\sooz\AppData\Local\Temp\pip-install-0jjhxyj3\dlib_489a4507707a49f6becd53489abedb63\build\temp.win-amd64-3.10\Release\dlib_build\dlib.vcxproj]
C:\Users\sooz\AppData\Local\Temp\pip-install-0jjhxyj3\dlib_489a4507707a49f6becd53489abedb63\dlib\external\zlib\gzwrite.c(212,24): warning C4267: '=': conversion from 'size_t' to 'unsigned int', possible loss of data [C:\Users\sooz\AppData\Local\Temp\pip-install-0jjhxyj3\dlib_489a4507707a49f6becd53489abedb63\build\temp.win-amd64-3.10\Release\dlib_build\dlib.vcxproj]
C:\Users\sooz\AppData\Local\Temp\pip-install-0jjhxyj3\dlib_489a4507707a49f6becd53489abedb63\dlib\external\zlib\gzread.c(472,18): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data [C:\Users\sooz\AppData\Local\Temp\pip-install-0jjhxyj3\dlib_489a4507707a49f6becd53489abedb63\build\temp.win-amd64-3.10\Release\dlib_build\dlib.vcxproj]
C:\Users\sooz\AppData\Local\Temp\pip-install-0jjhxyj3\dlib_489a4507707a49f6becd53489abedb63\dlib\external\zlib\gzwrite.c(232,21): warning C4267: '=': conversion from 'size_t' to 'unsigned int', possible loss of data [C:\Users\sooz\AppData\Local\Temp\pip-install-0jjhxyj3\dlib_489a4507707a49f6becd53489abedb63\build\temp.win-amd64-3.10\Release\dlib_build\dlib.vcxproj]
C:\Users\sooz\AppData\Local\Temp\pip-install-0jjhxyj3\dlib_489a4507707a49f6becd53489abedb63\dlib\external\zlib\gzwrite.c(371,19): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data [C:\Users\sooz\AppData\Local\Temp\pip-install-0jjhxyj3\dlib_489a4507707a49f6becd53489abedb63\build\temp.win-amd64-3.10\Release\dlib_build\dlib.vcxproj]
  trees.c
  uncompr.c
  zutil.c
  jaricom.c
  jcapimin.c
  jcapistd.c
  jcarith.c
  jccoefct.c
  jccolor.c
  jcdctmgr.c
  jchuff.c
  jcinit.c
  jcmainct.c
  jcmarker.c
  jcmaster.c
  jcomapi.c
  jcparam.c
  jcprepct.c
  jcsample.c
  jdapimin.c
  jdapistd.c
  jdarith.c
  jdatadst.c
  jdatasrc.c
  jdcoefct.c
C:\Users\sooz\AppData\Local\Temp\pip-install-0jjhxyj3\dlib_489a4507707a49f6becd53489abedb63\dlib\external\libjpeg\jdatadst.c(185,34): warning C4267: '=': conversion from 'size_t' to 'unsigned long', possible loss of data [C:\Users\sooz\AppData\Local\Temp\pip-install-0jjhxyj3\dlib_489a4507707a49f6becd53489abedb63\build\temp.win-amd64-3.10\Release\dlib_build\dlib.vcxproj]
  jdcolor.c
  jddctmgr.c
  jdhuff.c
  jdinput.c
  jdmainct.c
  jdmarker.c
  jdmaster.c
  jdmerge.c
  jdpostct.c
  jdsample.c
  jerror.c
  jfdctflt.c
  jfdctfst.c
  jfdctint.c
  jidctflt.c
C:\Users\sooz\AppData\Local\Temp\pip-install-0jjhxyj3\dlib_489a4507707a49f6becd53489abedb63\dlib\external\libjpeg\jerror.c(193,5): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [C:\Users\sooz\AppData\Local\Temp\pip-install-0jjhxyj3\dlib_489a4507707a49f6becd53489abedb63\build\temp.win-amd64-3.10\Release\dlib_build\dlib.vcxproj]
  jidctfst.c
0jjhxyj3\dlib_489a4507707a49f6becd53489abedb63\setup.py", line 222, in <module>
    setup(
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.240.0_x64__qbz5n2kfra8p0\lib\site-packages\setuptools\__init__.py", line 153, in setup
    return distutils.core.setup(**attrs)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.240.0_x64__qbz5n2kfra8p0\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.240.0_x64__qbz5n2kfra8p0\lib\distutils\dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.240.0_x64__qbz5n2kfra8p0\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.240.0_x64__qbz5n2kfra8p0\lib\site-packages\setuptools\command\install.py", line 61, in run
    return orig.install.run(self)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.240.0_x64__qbz5n2kfra8p0\lib\distutils\command\install.py", line 568, in run
    self.run_command('build')
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.240.0_x64__qbz5n2kfra8p0\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.240.0_x64__qbz5n2kfra8p0\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.240.0_x64__qbz5n2kfra8p0\lib\distutils\command\build.py", line 135, in run
    self.run_command(cmd_name)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.240.0_x64__qbz5n2kfra8p0\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.240.0_x64__qbz5n2kfra8p0\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\Users\sooz\AppData\Local\Temp\pip-install-0jjhxyj3\dlib_489a4507707a49f6becd53489abedb63\setup.py", line 134, in run
    self.build_extension(ext)
  File "C:\Users\sooz\AppData\Local\Temp\pip-install-0jjhxyj3\dlib_489a4507707a49f6becd53489abedb63\setup.py", line 174, in build_extension
    subprocess.check_call(cmake_build, cwd=build_folder)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.240.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--config', 'Release', '--', '/m']' returned non-zero exit status 1.
----------------------------------------

Upvotes: 3

Views: 24309

Answers (4)

Awal
Awal

Reputation: 178

If your default python is 2.*, then try this.

pip3 install cmake 
pip3 install dlib -vvv

Upvotes: 0

Deepak Raj
Deepak Raj

Reputation: 501

Please Install cmake threw pip and then install dlib.

This solution worked for me on ubuntu. If anyone facing same issue on ubuntu os. Please try this one.

pip install cmake
pip install dlib -vvv

Upvotes: 1

jloh
jloh

Reputation: 401

The Short Way

You can try this wheel I've compiled for dlib v19.22 without CUDA

pip install https://github.com/jloh02/dlib/releases/download/v19.22/dlib-19.22.99-cp310-cp310-win_amd64.whl
  • Python Version: 3.10
  • dlib Version: 19.22.99
  • Platform: Windows 10 64-bit
  • C++ Compiler: MSVC 19.29.30133.0

Manual Installation

1. Install cmake via Windows Installer from https://cmake.org/download/

Do not use pip as the developer has recommended in setup.py:

install_requires=['cmake'], # removed because the pip cmake package is busted, maybe someday it will be usable.

2. Clone the latest dlib repo

Shortcut: If you're compiling for v19.22 (Latest as of date is v19.22), you may use my already modified GitHub repo at https://github.com/jloh02/dlib/ and skip step 3

git clone https://github.com/davisking/dlib

IMPORTANT: Ensure you clone the repo into the same drive (Usually C:/) as your Python installation. Use the drive with your AppData where Python is executed.

3. Change the numpy.h file to make it Windows compatible

If you were to run python setup.py install now (don't run it yet), it would produce an error of defined type: ssize_t. This is because the "signed size_t" data type can only be found in Unix systems. A similar type SSIZE_T can be found in <BaseTsd.h> for Windows.

As recommended in this GitHub issue, in dlib/external/pybind11/include/pybind11/numpy.h:

Replace

#if defined(_MSC_VER)
#  pragma warning(push)
#  pragma warning(disable: 4127) // warning C4127: Conditional expression is constant
#endif

with

#if defined(_MSC_VER)
#  pragma warning(push)
#  pragma warning(disable: 4127) // warning C4127: Conditional expression is constant
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#endif

4. Installing dlib

Open a terminal in Administrator Mode (I used Powershell 7) and run

python setup.py install

References

Upvotes: 13

Juan Alvarado
Juan Alvarado

Reputation: 1

May you need to downgrade your pyhton to 3.6 instead of 3.10, then reload cmake

Upvotes: 0

Related Questions