簡體   English   中英

嘗試使用 pip 安裝 Dlib 時出錯。 蘋果系統

[英]Error when I try to install Dlib with pip. macOS

無法使用 pip install Dlib 安裝 Dlib,它給了我這個錯誤:

WARNING: The directory '/Users/myusername/Library/Caches/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting dlib
  Downloading dlib-19.19.0.tar.gz (3.2 MB)
     |████████████████████████████████| 3.2 MB 1.8 MB/s 
Building wheels for collected packages: dlib
  Building wheel for dlib (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /opt/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-884s1u35/dlib/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-884s1u35/dlib/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 /private/tmp/pip-wheel-lj7iq51r
       cwd: /private/tmp/pip-install-884s1u35/dlib/
  Complete output (69 lines):
  running bdist_wheel
  running build
  running build_py
  package init file 'dlib/__init__.py' not found (or not a regular file)
  running build_ext
  Building extension for Python 3.7.6 (default, Jan  8 2020, 13:42:34)
  Invoking CMake setup: 'cmake /private/tmp/pip-install-884s1u35/dlib/tools/python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/private/tmp/pip-install-884s1u35/dlib/build/lib.macosx-10.9-x86_64-3.7 -DPYTHON_EXECUTABLE=/opt/anaconda3/bin/python -DCMAKE_BUILD_TYPE=Release'
  -- The C compiler identification is unknown
  -- The CXX compiler identification is unknown
  -- Check for working C compiler: /usr/bin/cc
  -- Check for working C compiler: /usr/bin/cc -- broken
  CMake Error at /opt/anaconda3/lib/python3.7/site-packages/cmake/data/CMake.app/Contents/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:60 (message):
    The C compiler

      "/usr/bin/cc"

    is not able to compile a simple test program.

    It fails with the following output:

      Change Dir: /tmp/pip-install-884s1u35/dlib/build/temp.macosx-10.9-x86_64-3.7/CMakeFiles/CMakeTmp

      Run Build Command(s):/usr/bin/make cmTC_fe1fa/fast && xcrun: error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist
      Use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, or use `xcode-select --install` to install the standalone command line developer tools.
      See `man xcode-select` for more details.





    CMake will not be able to correctly generate this project.
  Call Stack (most recent call first):
    CMakeLists.txt:3 (project)


  -- Configuring incomplete, errors occurred!
  See also "/tmp/pip-install-884s1u35/dlib/build/temp.macosx-10.9-x86_64-3.7/CMakeFiles/CMakeOutput.log".
  See also "/tmp/pip-install-884s1u35/dlib/build/temp.macosx-10.9-x86_64-3.7/CMakeFiles/CMakeError.log".
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/private/tmp/pip-install-884s1u35/dlib/setup.py", line 261, in <module>
      'Topic :: Software Development',
    File "/opt/anaconda3/lib/python3.7/site-packages/setuptools/__init__.py", line 144, in setup
      return distutils.core.setup(**attrs)
    File "/opt/anaconda3/lib/python3.7/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/opt/anaconda3/lib/python3.7/distutils/dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "/opt/anaconda3/lib/python3.7/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/opt/anaconda3/lib/python3.7/site-packages/wheel/bdist_wheel.py", line 223, in run
      self.run_command('build')
    File "/opt/anaconda3/lib/python3.7/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/opt/anaconda3/lib/python3.7/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/opt/anaconda3/lib/python3.7/distutils/command/build.py", line 135, in run
      self.run_command(cmd_name)
    File "/opt/anaconda3/lib/python3.7/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/opt/anaconda3/lib/python3.7/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/private/tmp/pip-install-884s1u35/dlib/setup.py", line 135, in run
      self.build_extension(ext)
    File "/private/tmp/pip-install-884s1u35/dlib/setup.py", line 172, in build_extension
      subprocess.check_call(cmake_setup, cwd=build_folder)
    File "/opt/anaconda3/lib/python3.7/subprocess.py", line 363, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['cmake', '/private/tmp/pip-install-884s1u35/dlib/tools/python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/private/tmp/pip-install-884s1u35/dlib/build/lib.macosx-10.9-x86_64-3.7', '-DPYTHON_EXECUTABLE=/opt/anaconda3/bin/python', '-DCMAKE_BUILD_TYPE=Release']' returned non-zero exit status 1.
  ----------------------------------------
  ERROR: Failed building wheel for dlib
  Running setup.py clean for dlib
Failed to build dlib
Installing collected packages: dlib
    Running setup.py install for dlib ... error
    ERROR: Command errored out with exit status 1:
     command: /opt/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-884s1u35/dlib/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-884s1u35/dlib/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/tmp/pip-record-2gwrjrbi/install-record.txt --single-version-externally-managed --compile --install-headers /opt/anaconda3/include/python3.7m/dlib
         cwd: /private/tmp/pip-install-884s1u35/dlib/
    Complete output (71 lines):
    running install
    running build
    running build_py
    package init file 'dlib/__init__.py' not found (or not a regular file)
    running build_ext
    Building extension for Python 3.7.6 (default, Jan  8 2020, 13:42:34)
    Invoking CMake setup: 'cmake /private/tmp/pip-install-884s1u35/dlib/tools/python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/private/tmp/pip-install-884s1u35/dlib/build/lib.macosx-10.9-x86_64-3.7 -DPYTHON_EXECUTABLE=/opt/anaconda3/bin/python -DCMAKE_BUILD_TYPE=Release'
    -- The C compiler identification is unknown
    -- The CXX compiler identification is unknown
    -- Check for working C compiler: /usr/bin/cc
    -- Check for working C compiler: /usr/bin/cc -- broken
    CMake Error at /opt/anaconda3/lib/python3.7/site-packages/cmake/data/CMake.app/Contents/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:60 (message):
      The C compiler

        "/usr/bin/cc"

      is not able to compile a simple test program.

      It fails with the following output:

        Change Dir: /tmp/pip-install-884s1u35/dlib/build/temp.macosx-10.9-x86_64-3.7/CMakeFiles/CMakeTmp

        Run Build Command(s):/usr/bin/make cmTC_f5f8f/fast && xcrun: error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist
        Use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, or use `xcode-select --install` to install the standalone command line developer tools.
        See `man xcode-select` for more details.





      CMake will not be able to correctly generate this project.
    Call Stack (most recent call first):
      CMakeLists.txt:3 (project)


    -- Configuring incomplete, errors occurred!
    See also "/tmp/pip-install-884s1u35/dlib/build/temp.macosx-10.9-x86_64-3.7/CMakeFiles/CMakeOutput.log".
    See also "/tmp/pip-install-884s1u35/dlib/build/temp.macosx-10.9-x86_64-3.7/CMakeFiles/CMakeError.log".
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/tmp/pip-install-884s1u35/dlib/setup.py", line 261, in <module>
        'Topic :: Software Development',
      File "/opt/anaconda3/lib/python3.7/site-packages/setuptools/__init__.py", line 144, in setup
        return distutils.core.setup(**attrs)
      File "/opt/anaconda3/lib/python3.7/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/opt/anaconda3/lib/python3.7/distutils/dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "/opt/anaconda3/lib/python3.7/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/opt/anaconda3/lib/python3.7/site-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/opt/anaconda3/lib/python3.7/distutils/command/install.py", line 545, in run
        self.run_command('build')
      File "/opt/anaconda3/lib/python3.7/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/opt/anaconda3/lib/python3.7/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/opt/anaconda3/lib/python3.7/distutils/command/build.py", line 135, in run
        self.run_command(cmd_name)
      File "/opt/anaconda3/lib/python3.7/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/opt/anaconda3/lib/python3.7/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/private/tmp/pip-install-884s1u35/dlib/setup.py", line 135, in run
        self.build_extension(ext)
      File "/private/tmp/pip-install-884s1u35/dlib/setup.py", line 172, in build_extension
        subprocess.check_call(cmake_setup, cwd=build_folder)
      File "/opt/anaconda3/lib/python3.7/subprocess.py", line 363, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['cmake', '/private/tmp/pip-install-884s1u35/dlib/tools/python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/private/tmp/pip-install-884s1u35/dlib/build/lib.macosx-10.9-x86_64-3.7', '-DPYTHON_EXECUTABLE=/opt/anaconda3/bin/python', '-DCMAKE_BUILD_TYPE=Release']' returned non-zero exit status 1.
    ----------------------------------------
ERROR: Command errored out with exit status 1: /opt/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-884s1u35/dlib/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-884s1u35/dlib/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/tmp/pip-record-2gwrjrbi/install-record.txt --single-version-externally-managed --compile --install-headers /opt/anaconda3/include/python3.7m/dlib Check the logs for full command output.

我在 macOS Catalina 10.15.3 上。 我安裝了 Anaconda 和 cmake。 我對堆棧溢出很陌生。 我安裝了多個版本的python(不知道是不是有問題)我主要使用3.7。

我以前從未在論壇上看到過這些錯誤。 我不知道該怎么辦! 謝謝您的幫助!

檢查您的輸出。 控制台具體告訴你:

It fails with the following output:

        Change Dir: /tmp/pip-install-884s1u35/dlib/build/temp.macosx-10.9-x86_64-3.7/CMakeFiles/CMakeTmp

        Run Build Command(s):/usr/bin/make cmTC_f5f8f/fast && xcrun: error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist
        Use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, or use `xcode-select --install` to install the standalone command line developer tools.
        See `man xcode-select` for more details.

CMake 需要 XCode 命令行開發工具才能構建項目。

所以打開Terminal ,然后運行:

sudo xcode-select --install

或者,如果您知道之前已經安裝過它,請指向安裝了工具的 Xcode:

sudo xcode-select --switch path/to/Xcode.app

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM