build icon indicating copy to clipboard operation
build copied to clipboard

Boost.Python can not find python on windows if path contains spaces

Open Grantim opened this issue 3 years ago • 1 comments

This issue was mentioned here, when building boost.python with numpy. Everything is ok if python is installed in path without spaces, and it does not find system python (and thereafter numpy) if spaces are present in the path. So attached file can be applied as patch (mb it is not the best fix, but still works, please have a look).

I faced this issue on boost version 1.75.0

Grantim avatar Jul 07 '21 16:07 Grantim

I have the same issue with current boost 1.80. I just need to build the boost libraries on Windows (using vc143) and choose correct python interpreter. I have 32-bit python installed in standard location: C:\Program Files (x86)\Python310-32 There is no python configured on system path nor in system variables. I bootstrap the boost and enter python configuration either to project-config.jam or to tools\build\src\user-config.jam or tools\build\src\site-config.jam:

using python : : "C:/Program Files (x86)/Python310-32/python.exe" ;

or:

using python : : "C:\\Program Files (x86)\\Python310-32\\python.exe" ;

Result:

notice: [python-cfg] Configuring python...
notice: [python-cfg]   user-specified cmd-or-prefix: "C:/Program Files (x86)/Python310-32/python.exe"
notice: [python-cfg] Checking interpreter command "C:/Program Files (x86)/Python310-32/python.exe"...
notice: [python-cfg] running command 'DIR /-C /A:S "C:\Program Files (x86)\Python310-32\python.exe" 2>&1'
notice: [python-cfg] running command 'C:/Program Files (x86)/Python310-32/python.exe -c "from sys import *; print('version=%d.%d\nplatform=%s\nprefix=%s\nexec_prefix=%s\nexecutable=%s' % (version_info[0],version_info[1],platform,prefix,exec_prefix,executable))" 2>&1'
notice: [python-cfg] ...does not invoke a working interpreter

Note that:

  • configuration and path is picked up correctly
  • interpreter command is checked correctly
  • but when running python script via command line parameter, interpreter is run incorrectly without "", so it is probably trying to run C:/Program

That being said, there is definitely problem with spaces in the path. When I change the setting to ancient 8.3 compatibility format:

using python : : c:/PROGRA~2/PYTHON~1/python.exe ;

Then it runs correctly:

notice: [python-cfg] Configuring python...
notice: [python-cfg]   user-specified cmd-or-prefix: "c:/PROGRA~2/PYTHON~1/python.exe"
notice: [python-cfg] Checking interpreter command "c:/PROGRA~2/PYTHON~1/python.exe"...
notice: [python-cfg] running command 'DIR /-C /A:S "C:\Program Files (x86)\Python310-32\python.exe" 2>&1'
notice: [python-cfg] running command 'c:/PROGRA~2/PYTHON~1/python.exe -c "from sys import *; print('version=%d.%d\nplatform=%s\nprefix=%s\nexec_prefix=%s\nexecutable=%s' % (version_info[0],version_info[1],platform,prefix,exec_prefix,executable))" 2>&1'
notice: [python-cfg] ...requested configuration matched!
notice: [python-cfg] Details of this Python configuration:
notice: [python-cfg]   interpreter command: "c:/PROGRA~2/PYTHON~1/python.exe"
notice: [python-cfg]   include path: "c:\PROGRA~2\PYTHON~1\Include"
notice: [python-cfg]   library path: "c:\PROGRA~2\PYTHON~1\libs"
notice: [python-cfg]   DLL search path: "c:\PROGRA~2\PYTHON~1"

pavel-machyniak avatar Aug 22 '22 18:08 pavel-machyniak