Search code examples
visual-studio-codeinstallationmoduleanacondadetectron

I can't install the module detectron2 for python


I tried many times to install the library . It always ended up with a different error. I tried to install the detectron environment thanks to anaconda. I used the same interpreter in Visual studio code. The last error is :

""" Requirement already satisfied: oauthlib>=3.0.0 in c:\users\chloe\miniconda3\envs\detectron_env\lib\site-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard->detectron2==0.6) (3.2.2) Installing collected packages: detectron2 Running setup.py develop for detectron2 error: subprocess-exited-with-error

× python setup.py develop did not run successfully.
│ exit code: 1
╰─> [18 lines of output]
    running develop
    running egg_info
    writing detectron2.egg-info\PKG-INFO
    writing dependency_links to detectron2.egg-info\dependency_links.txt
    writing requirements to detectron2.egg-info\requires.txt
    writing top-level names to detectron2.egg-info\top_level.txt
    reading manifest file 'detectron2.egg-info\SOURCES.txt'
    adding license file 'LICENSE'
    writing manifest file 'detectron2.egg-info\SOURCES.txt'
    running build_ext
    building 'detectron2._C' extension
    C:\Users\chloe\miniconda3\envs\detectron_env\lib\site-packages\setuptools\command\easy_install.py:144: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
      warnings.warn(
    C:\Users\chloe\miniconda3\envs\detectron_env\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
      warnings.warn(
    C:\Users\chloe\miniconda3\envs\detectron_env\lib\site-packages\torch\utils\cpp_extension.py:359: UserWarning: Error checking compiler version for cl: [WinError 2] Le fichier spécifié est introuvable
      warnings.warn(f'Error checking compiler version for {compiler}: {error}')
    error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
    [end of output]

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

error: subprocess-exited-with-error

× python setup.py develop did not run successfully. │ exit code: 1 ╰─> [18 lines of output] running develop running egg_info writing detectron2.egg-info\PKG-INFO writing dependency_links to detectron2.egg-info\dependency_links.txt writing requirements to detectron2.egg-info\requires.txt writing top-level names to detectron2.egg-info\top_level.txt reading manifest file 'detectron2.egg-info\SOURCES.txt' adding license file 'LICENSE' writing manifest file 'detectron2.egg-info\SOURCES.txt' running build_ext building 'detectron2._C' extension C:\Users\chloe\miniconda3\envs\detectron_env\lib\site-packages\setuptools\command\easy_install.py:144: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools. warnings.warn( C:\Users\chloe\miniconda3\envs\detectron_env\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( C:\Users\chloe\miniconda3\envs\detectron_env\lib\site-packages\torch\utils\cpp_extension.py:359: UserWarning: Error checking compiler version for cl: [WinError 2] Le fichier spécifié est introuvable warnings.warn(f'Error checking compiler version for {compiler}: {error}') error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. """

I have already installed Microsoft Visual, my version is 17.5.3 I don't understand what I'm supposed to do.


Solution

  • You will need to install Visual studio as per error messsage:

    Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/