简体   繁体   中英

Problem in installing dlib in PyCharm (macOS)

I am a beginner in the Python programming language. I am Working on a project for facial landmark detection in Python. For this I am trying to use dlib.

I am using PyCharm IDE for Python programming language, but when I am trying to install dlib library on my PyCharm package then I am getting the following error.

错误

Can anyone please help me solving this.

Edit: Here is the complete error that I am getting.

**Collecting dlib Using cached https://files.pythonhosted.org/packages/05/57/e8a8caa3c89a27f80bc78da39c423e2553f482a3705adc619176a3a24b36/dlib-19.17.0.tar.gz Installing collected packages: dlib Running setup.py install for dlib: started Running setup.py install for dlib: finished with status 'error' Complete output from command /Users/mayanktiwari/human_detect/untitled/bin/python -u -c "import setuptools, tokenize; file ='/private/var/folders/ww/21lp_4013plfs5g1ym7wh39h0000gn/T/pycharm-packaging/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/var/folders/ww/21lp_4013plfs5g1ym7wh39h0000gn/T/pip-record-hq673j64/install-record.txt --single-version-externally-managed --compile --install-headers /Users/mayanktiwari/human_detect/untitled/include/site/python3.7/dlib: running install running build running build_py package init file 'dlib/ init .py' not found (or not a regular fi le) warning: build_py: byte-compiling is disabled, skipping.

running build_ext
Building extension for Python 3.7.2 (default, Dec 27 2018, 07:35:52)
Invoking CMake setup: 'cmake /private/var/folders/ww/21lp_4013plfs5g1ym7wh39h0000gn/T/pycharm-packaging/dlib/tools/python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/private/var/folders/ww/21lp_4013plfs5g1ym7wh39h0000gn/T/pycharm-packaging/dlib/build/lib.macosx-10.13-x86_64-3.7 -DPYTHON_EXECUTABLE=/Users/mayanktiwari/human_detect/untitled/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 /usr/local/Cellar/cmake/3.13.2/share/cmake/Modules/CMakeTestCCompiler.cmake:52 (message):
  The C compiler

    "/usr/bin/cc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /private/var/folders/ww/21lp_4013plfs5g1ym7wh39h0000gn/T/pycharm-packaging/dlib/build/temp.macosx-10.13-x86_64-3.7/CMakeFiles/CMakeTmp

    Run Build Command:"/usr/bin/make" "cmTC_dc7d9/fast"
    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun




  CMake will not be able to correctly generate this project.


-- Configuring incomplete, errors occurred!
See also "/private/var/folders/ww/21lp_4013plfs5g1ym7wh39h0000gn/T/pycharm-packaging/dlib/build/temp.macosx-10.13-x86_64-3.7/CMakeFiles/CMakeOutput.log".
See also "/private/var/folders/ww/21lp_4013plfs5g1ym7wh39h0000gn/T/pycharm-packaging/dlib/build/temp.macosx-10.13-x86_64-3.7/CMakeFiles/CMakeError.log".
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/private/var/folders/ww/21lp_4013plfs5g1ym7wh39h0000gn/T/pycharm-packaging/dlib/setup.py", line 261, in <module>
    'Topic :: Software Development',
  File "/Users/mayanktiwari/human_detect/untitled/lib/python3.7/site-packages/setuptools-40.8.0-py3.7.egg/setuptools/__init__.py", line 145, in setup
  File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/Users/mayanktiwari/human_detect/untitled/lib/python3.7/site-packages/setuptools-40.8.0-py3.7.egg/setuptools/command/install.py", line 61, in run
  File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/command/install.py", line 545, in run
    self.run_command('build')
  File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/command/build.py", line 135, in run
    self.run_command(cmd_name)
  File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/private/var/folders/ww/21lp_4013plfs5g1ym7wh39h0000gn/T/pycharm-packaging/dlib/setup.py", line 135, in run
    self.build_extension(ext)
  File "/private/var/folders/ww/21lp_4013plfs5g1ym7wh39h0000gn/T/pycharm-packaging/dlib/setup.py", line 172, in build_extension
    subprocess.check_call(cmake_setup, cwd=build_folder)
  File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 347, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '/private/var/folders/ww/21lp_4013plfs5g1ym7wh39h0000gn/T/pycharm-packaging/dlib/tools/python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/private/var/folders/ww/21lp_4013plfs5g1ym7wh39h0000gn/T/pycharm-packaging/dlib/build/lib.macosx-10.13-x86_64-3.7', '-DPYTHON_EXECUTABLE=/Users/mayanktiwari/human_detect/untitled/bin/python', '-DCMAKE_BUILD_TYPE=Release']' returned non-zero exit status 1.

----------------------------------------

Command "/Users/mayanktiwari/human_detect/untitled/bin/python -u -c "import setuptools, tokenize; file ='/private/var/folders/ww/21lp_4013plfs5g1ym7wh39h0000gn/T/pycharm-packaging/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/var/folders/ww/21lp_4013plfs5g1ym7wh39h0000gn/T/pip-record-hq673j64/install-record.txt --single-version-externally-managed --compile --install-headers /Users/mayanktiwari/human_detect/untitled/include/site/python3.7/dlib" failed with error code 1 in /private/var/folders/ww/21lp_4013plfs5g1ym7wh39h0000gn/T/pycharm-packaging/dlib/**

conda install cmake

Then

pip install dlib

It works for me.

Refer Answer from this link and try, circleci: pip install dlib fails

you can download Anaconda from here, https://www.anaconda.com/distribution/#download-section

And all package can found in, https://repo.anaconda.com/pkgs/main/win-64/

I have found the answer to this question. We just need to follow simple steps to install dlib in Python.

  1. Install Python
  2. Install Pycharm
  3. Install Anaconda

Open anaconda, create a new enviornment, and then execute the following commands in the same order.

  • conda update conda

  • conda update anaconda

  • conda install cmake

  • conda install -c conda-forge dlib

Now in this way you can install dlib on anaconda's virtual enviornment. Next you can access this virtual enviornment inside your Pycharm editor.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM