Closed TAMILVIP007 closed 2 years ago
Do you have Cmake installed? https://cmake.org/download/ make sure to add it into PATH
Do you have Cmake installed? https://cmake.org/download/ make sure to add it into PATH
Yeh it is
hey Indrajeeth @TAMILVIP007 how did u fix this?? i (and my teammates too) are facing exactly same issue (https://github.com/davisking/dlib/issues/2801)
python
: 3.11.2 (via python.org installer)pip
: 23.1.2bash
(via msys2) (UPDATE: same happens with cmd
)cmake
: 3.26.4 (mingw-w64 via msys2)g++
: g++ (GCC) 11.3.0 (msys2)$ pip install dlib --verbose
cmake
invocation breakdowncmake %LOCALAPPDATA%\Temp\pip-install-m4l_t_ho\dlib_3eca10703e464ad1a0cbb41bdcc2b738\tools\python
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=%LOCALAPPDATA%\Temp\pip-install-m4l_t_ho\dlib_3eca10703e464ad1a0cbb41bdcc2b738\build\lib.win-amd64-cpython-311
-DPYTHON_EXECUTABLE=D:\15_devt\GitHub\oooo\.venv\Scripts\python.exe
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=%LOCALAPPDATA%\Temp\pip-install-m4l_t_ho\dlib_3eca10703e464ad1a0cbb41bdcc2b738\build\lib.win-amd64-cpython-311
-A x64
Do you have Visual C++ installed?
Do you have Visual C++ installed?
nope... but that shouldn't be required either; per the official documentation:
Note that you need to have CMake and a working C++ compiler installed for this to work. - Using dlib from Python http://dlib.net/compile.html
or am i missing something?
Well, what you say about the documentation seems right, it doesn't specify Visual C++ for Windows. But in the error log you uploaded says:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
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++.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
So I guess you need to install that one.
Just to be clear, I hardly ever use Windows, and I've never used dlib with Python, I'm just trying to help. If that doesn't work, maybe someone else can give you a hand.
self hiding as offtopic
[build-system]
section if i am right....Also, same error is shown on trying to python -m build --wheel
https://github.com/davisking/dlib/blob/3f9c5c1cfdd9c861be1e36ecc166f81b90656205/README.md#L48
hey @davisking
I am sorry to ask like this, but can u please help look into this.
i have tried looking
-G msys
for cmake while pip install
-ingbut nothing seem to be working and is failing one way or the another... please help 🙏🙏
Well, what you say about the documentation seems right, it doesn't specify Visual C++ for Windows. But in the error log you uploaded says:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 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++. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
So I guess you need to install that one.
This is the answer. You have to do like these instructions say. That is, for windows, python (not dlib) requires visual studio to build python extensions.
for windows, python (not dlib) requires visual studio ... - @ davisking at https://github.com/davisking/dlib/issues/2652#issuecomment-1639165720
thanks a lot for clearing that up.
so there's no way to use the msys toolchain while installing from python?
if no, then i would prefer compiling dlib separately and use it in python somehow ... if thats possible
i had looked through the dlib.net but in context of buiding with cmake, it only mentions "compile examples" and never how to compile the library to wheel itself.
Edit: now that i mention this, i recall i saw a tutorial compiling to .o
object file via toolchain of choice and from there to .whl
wheel via pip.... I wii try that.
Would u like to know updates on this approach and see how it went?
I also wondor how do other python libs written in C/++ like numpy etc compile then? I didnt face any issues installing those via pip
.
Q: no way to use msys ...? A: seems no! msys2/python » "the official CPython implementation doesn't support building with GCC/Clang on Windows ..."
Q: tutorial for compiling to .o, then to .whl ... A: can't find that now
^
https://pypi.org/project/<lib_name>
. On the page that follows, the string after libName-libVer-
represents the python distribution that wheel is intended for. So, cp36
means cpython-3.6 and so on.Aside: Following reminded me that some of these pac-mans mentioned that they fetch packages from community distributed builds... so, maybe going the conda / mamba / micromamba route can save me... 'will see.
Try
conda install -c menpo dlib
- @rendicahya at https://github.com/davisking/dlib/issues/218#issuecomment-279689660Thanks a lot, it worked for me too. - @sonineha2191 at https://github.com/davisking/dlib/issues/218#issuecomment-557051243
have you tried this?
conda install -c conda-forge dlib=19.4
- @anoumaru at https://github.com/davisking/dlib/issues/218#issuecomment-414132506 - @sonineha2191 at https://github.com/davisking/dlib/issues/218#issuecomment-570043654it solved my problem - @MengHao666 at https://github.com/davisking/dlib/issues/218#issuecomment-1084496270
these pac-mans mentioned that they fetch packages from community distributed builds
yeah, used micromamba with packages from the "channel" conda-forge, it fetched this thing for dlib, and finallyyyy it's working good :)
also, the version in conda-forge (at least for dlib) matches the one distributed at pypi (i.e. via pip): 19.24.2 :)
Name Version Build Channel
----------------------------------------------------------------------------------
dlib 19.24.2 py311he12e1e2_0 conda-forge
Visual studio is free. So you could download it and install in short order. For more details see https://docs.python.org/3/extending/windows.html. The notable detail is it also instructs you to use visual studio. If you want to do something else then you are on your own. I honestly don't know if it would be possible. I expect it would not work though.
If you want to do something else then you are on your own.
I honestly don't know if it would be possible. I expect it would not work though.
I dont understand what this meant. but i guess u are referring to using other package managers, and its possibility of failing.
accordingly: the conda
(or micromamba
in my case, hereafter referred as mmb) approach is used by Anaconda IDE, and is widely used as much commonly as pip
. also, after completing the setup with mmb, i ran my python program using dlib and it worked.
Visual studio is free. So you could download it and install in short order.
following may sound like a rant, but its not. I am just calmly laying down all the reasons why i didnt follow that way.
Visual Studio might be free (from a direct upfront monetary cost only), but its a ginormous bloat package, which as per this readme by charlielito file (mentioned at #218 comment) consumes 12GB just for download.
Also, like all MicroSoft products (see here for one example) , it doesn't mention upfront the download & install size required. And i assume it wont tell even while downloading either.
These all things make me feel even more helpless, and like a puppet. Alongwith; it also has an unproductive financial, mental & huge time toll:
Even after finishing the download:
All this is just not worth it for me. I strive to avoid such trapes at all upfront costs.
the fact that MS distributes the only directly available & "recommended for their OS by tonnes of other softwares" compiler - only as bundled with their IDE is already telling - forced funnel marketing pretty much.
Contrast this with other way, u just spend time actually learning the stuff once, and it most likely remains reproducible in future. no repeated and constant tortures (for lack of a better word at hand).
the download size is communicated beforehand, i am not treated like an illiterate and spoonfed blindly with bloat.
Yeah I feel you. I loath needing to turn on visual studio or deal with it. This stuff is outside my control though. Like what you did was just find some other package system where someone else built dlib with visual studio for you. I really don't want to get into the binary package game, especially on windows, in part because of the issues you mentioned with visual studio. But that is just the tip of the iceberg.
The other problem you will find with these binary dlib packages is they are built to lowest common denominator hardware. So it will be slower than if you built it yourself. E.g. it probably isn't built to use AVX instructions. And I wager it isn't built with CUDA or cuDNN either. And I definitely do not want to get into the repackaging nvidia binaries, that's even more frustrating than dealing with visual studio.
Actually, I've been thinking about how to solve this problem, too, since a big chunk of the issues that people open here are related to Windows installation and MSVC.
For some time now, I've been keeping an eye on Zig.
I got interested in it for several reasons, but one of them is that it ships with Clang, so it's able to build C++ code.
You just download the binary for your platform from their website and type zig c++
and you get access to a ready to roll C++ compiler (it's just Clang).
So maybe then, just running CC="zig cc" CXX="zig c++" cmake -B build
should work. I need to try it, though.
Furthermore, if I made a build.zig
that compiles dlib, then the compilation would be trivial on all platforms: just run zig build
and done. You could even cross-compile easily, just by passing the target OS as a flag to the command line.
I don't know how hard it is to get CMake feature parity, but I am certainly willing to try. That should probably not be the recommended way of installing dlib if you want to use it as a library, though.
However, being able to build the python module using zig build
would be a game changer for Python users, especially those on Windows.
Here's an example of a C project that uses the Zig build system: raylib
EDIT: another example, the creator of Zig also ported FFmpeg to the Zig build system: https://github.com/andrewrk/ffmpeg
That would be neat. It's got to be able to produce dll files that can be loaded by a binary built by visual studio (i.e. the python interpreter). That's the real rub. Visual studio is sort of its own world when it comes to how that all works, which is a big part of the problem.
one long term possible solution for all this - can be to go to https://discuss.python.org/ and raise your voices and concern about supporting msys2-clang-toolchain as an alternate to MS-VS.
Many other people have done already, if more and more module maintainers raise this concern, then they surely will provide this.
The biggest part of the problem isn't anything the core python devs did or have control over either though. It's really due to the huge variability in C and C++ build systems, linking conventions, and so forth. It's not super clear to me there is much they can do either.
Yes, I was exposed to the linking conventions issue in here: https://github.com/davisking/dlib/discussions/2838 for the first time in my life.
I had always built everything with the same compiler, so far.
Yeah I'll be real surprised if that works :)
Maybe though. At some point something hopefully unseats visual studio. I kinda want clang to eat the world.
Oh, why is that? Ease of cross-platform development?
The biggest problem with C++ is how confusing the build process is to people. It's too easy to run into binary incompatibility or ODR problems.
But you could imagine some day there is some standard way to build. And then there can be some decent C++ package management.
Not going to hold my breath though. At its root this requires a bunch of organizations to all cohesively cooperate in a way you don't often see. And there is all this old stuff that needs to be incorporated somehow too. Like Fortran libraries.
Oh, yeah, that too…
hi again. can u share the dlib wheeels (i.e. .whl files) for windows with me - even if unofficially? 😓 i am having trouble getting other tools to work with micromamba: https://github.com/mamba-org/mamba/issues/2702
Aside:
microsoft so badly wanted me to leave windows. i will obey them soon - as i will never move to win 11 anyway. following happened when installing flutter sdk
[X] Visual Studio - develop for Windows
X Visual Studio not installed; this is necessary for Windows development.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
I don't have any dlib wheels.
running install C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\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\indrajeeth\AppData\Local\Programs\Python\Python310\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( running bdist_egg running egg_info creating tools\python\dlib.egg-info writing tools/python\dlib.egg-info\PKG-INFO writing dependency_links to tools/python\dlib.egg-info\dependency_links.txt writing top-level names to tools/python\dlib.egg-info\top_level.txt writing manifest file 'tools/python\dlib.egg-info\SOURCES.txt' reading manifest file 'tools/python\dlib.egg-info\SOURCES.txt' reading manifest template 'MANIFEST.in' no previously-included directories found matching 'tools\python\build' no previously-included directories found matching 'dlib\cmake_utils*\build' warning: no previously-included files matching '*.pyc' found anywhere in distribution adding license file 'LICENSE' adding license file 'LICENSE.txt' writing manifest file 'tools/python\dlib.egg-info\SOURCES.txt' installing library code to build\bdist.win-amd64\egg running install_lib running build_py running build_ext C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setup.py:129: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. if LooseVersion(cmake_version) < '3.1.0': Building extension for Python 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)] Invoking CMake setup: 'cmake C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\build\lib.win-amd64-cpython-310 -DPYTHON_EXECUTABLE=C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\build\lib.win-amd64-cpython-310 -A x64' 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! See also "C:/Users/indrajeeth/AppData/Local/Programs/Python/Python310/Lib/site-packages/build/temp.win-amd64-cpython-310/Release/CMakeFiles/CMakeOutput.log". Traceback (most recent call last): File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setup.py", line 222, in
setup(
File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools__init__.py", line 87, in setup
return distutils.core.setup(**attrs)
File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools_distutils\core.py", line 185, in setup
return run_commands(dist) File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools_distutils\core.py", line 201, in run_commands dist.run_commands() File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools_distutils\dist.py", line 973, in run_commands self.run_command(cmd) File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools\dist.py", line 1217, in run_command
super().run_command(command) File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools_distutils\dist.py", line 992, in run_command cmd_obj.run() File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools\command\install.py", line 74, in run
self.do_egg_install() File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools\command\install.py", line 123, in do_egg_install self.run_command('bdist_egg') File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools_distutils\cmd.py", line 319, in run_command self.distribution.run_command(command) File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools\dist.py", line 1217, in run_command super().run_command(command) File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools_distutils\dist.py", line 992, in run_command cmd_obj.run() File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools\command\bdist_egg.py", line 165, in run cmd = self.call_command('install_lib', warn_dir=0) File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools\command\bdist_egg.py", line 151, in call_command self.run_command(cmdname) File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools_distutils\cmd.py", line 319, in run_command self.distribution.run_command(command) File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools\dist.py", line 1217, in run_command
super().run_command(command) File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools_distutils\dist.py", line 992, in run_command cmd_obj.run() File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools\command\install_lib.py", line 11, in run
self.build() File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools_distutils\command\install_lib.py", line 112, in build self.run_command('build_ext') File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools_distutils\cmd.py", line 319, in run_command self.distribution.run_command(command) File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools\dist.py", line 1217, in run_command
super().run_command(command) File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools_distutils\dist.py", line 992, in run_command cmd_obj.run() File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setup.py", line 134, in run self.build_extension(ext) File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setup.py", line 171, in build_extension subprocess.check_call(cmake_setup, cwd=build_folder) File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 369, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['cmake', 'C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\tools\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\build\lib.win-amd64-cpython-310', '-DPYTHON_EXECUTABLE=C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\build\lib.win-amd64-cpython-310', '-A', 'x64']' returned non-zero exit status 1.
i tried to install it in my windows but givin this error os - windowns 10 py version 3.10 vs studio code is installed but still gettin this error