Closed Kasdision closed 6 years ago
@Erotemic #1982 I see this same problem, could tell me how to solve this problem? ps: I have tried to slove this by what you said in #1982 ,but it can't help
Yes, it seems that the newlines in stdout/stdin are actually not causing any issue.
I think the solution is that dedent
is giving an uninformative error message.
Did you try what I wrote in this comment?
So, I actually tested this on my windows box, but I was unable to reproduce the error when running via cmd.exe. Do you have python installed? Is python on the path?
What happens if you download this file: https://github.com/Erotemic/misc/blob/master/cmake/utils.cmake
and then run cmake -P utils.cmake?
@Erotemic Thank you for your reply, when I run cmake -P utils.cmake, I got error like this:
C:\Users\Administrator>cmake -P utils.cmake
CMake Warning (dev) at utils.cmake:76 (if):
if given arguments:
"TRUE"
An argument named "TRUE" appears in a conditional statement. Policy
CMP0012 is not set: if() recognizes numbers and boolean constants. Run
"cmake --help-policy CMP0012" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
This warning is for project developers. Use -Wno-dev to suppress it.
ERROR Failed to remove indentation from:
"""
from distutils import sysconfig
print(sysconfig.get_python_lib(prefix=''))
"""
Python dedent failed with error code: 系统找不到指定的文件。
CMake Error at utils.cmake:31 (message):
Python dedent failed with error code: 系统找不到指定的文件。
Call Stack (most recent call first):
utils.cmake:54 (dedent)
utils.cmake:97 (pycmd)
It seems like the same error to the "build_windows.bat", could I ask what's the problem it is?Is something about my python enviroment wrong?
Its very possible that something in your Python environment is wrong.
To remind myself, I'm posting that "系统找不到指定的文件" means: "System can't find the specified file.
In the same command prompt where you ran build_windows.bat can you run:
python -c "import textwrap; print(textwrap.__file__)"
and report the output?
Also change the function dedent in cmake as such:
function(dedent outvar text)
# Use PYTHON_EXECUTABLE if it is defined, otherwise default to python
if ("${PYTHON_EXECUTABLE}" STREQUAL "")
set(_python_exe "python")
else()
set(_python_exe "${PYTHON_EXECUTABLE}")
endif()
set(_fixup_cmd "import sys; from textwrap import dedent; print(dedent(sys.stdin.read()))")
# Use echo to pipe the text to python's stdinput. This prevents us from
# needing to worry about any sort of special escaping.
message(STATUS " PYTHON_EXECUTABLE: \"${PYTHON_EXECUTABLE}\"")
message(STATUS " _python_exe: \"${_python_exe}\"")
message(STATUS " _fixup_cmd: \"${_fixup_cmd}\"")
message(STATUS " text: \"${text}\"")
execute_process(
COMMAND echo "${text}"
COMMAND "${_python_exe}" -c "${_fixup_cmd}"
RESULT_VARIABLE _dedent_exitcode
OUTPUT_VARIABLE _dedent_text)
if(NOT ${_dedent_exitcode} EQUAL 0)
message(ERROR " Failed to remove indentation from: \n\"\"\"\n${text}\n\"\"\"
Python dedent failed with error code: ${_dedent_exitcode}")
message(FATAL_ERROR " Python dedent failed with error code: ${_dedent_exitcode}")
endif()
# Remove supurflous newlines (artifacts of print)
string(STRIP "${_dedent_text}" _dedent_text)
set(${outvar} "${_dedent_text}" PARENT_SCOPE)
endfunction()
and then report what the output is?
@Erotemic When I run:
python -c "import textwrap; print(textwrap.__file__)"
The output is:
C:\Users\Administrator>python -c "import textwrap; print(textwrap.__file__)"
C:\Python27\lib\textwrap.pyc
And when I replace the function dedent in cmake that you give, I got that:
C:\Users\Administrator>cmake -P utils.cmake
CMake Warning (dev) at utils.cmake:80 (if):
if given arguments:
"TRUE"
An argument named "TRUE" appears in a conditional statement. Policy
CMP0012 is not set: if() recognizes numbers and boolean constants. Run
"cmake --help-policy CMP0012" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
This warning is for project developers. Use -Wno-dev to suppress it.
-- PYTHON_EXECUTABLE: ""
-- _python_exe: "python"
-- _fixup_cmd: "import sys; from textwrap import dedent; print(dedent(sys.stdin.read()))"
-- text: "
from distutils import sysconfig
print(sysconfig.get_python_lib(prefix=''))
"
ERROR Failed to remove indentation from:
"""
from distutils import sysconfig
print(sysconfig.get_python_lib(prefix=''))
"""
Python dedent failed with error code: 系统找不到指定的文件。
CMake Error at utils.cmake:35 (message):
Python dedent failed with error code: 系统找不到指定的文件。
Call Stack (most recent call first):
utils.cmake:58 (dedent)
utils.cmake:101 (pycmd)
What does that mean? I just can not understand...
The first test was simply to verify that you had python in your path.
The second test was to show that cmake found python correctly, and sanity checks of the variable values that matter.
Looking at these results I don't see anything out of the ordinary.
What happens if you remove the line
COMMAND "${_python_exe}" -c "${_fixup_cmd}"
, does the command fail on the echo?
Lastly, we should try something simple like
execute_process(
COMMAND echo "${text}"
COMMAND "${_python_exe}" -c "print('hello_world')"
RESULT_VARIABLE _dedent_exitcode
OUTPUT_VARIABLE _dedent_text)
and check the values of _dedent_exitcode and _dedent_text
If these don't work does the error persist if you upgrade to Python3? Python2 only has a few years of support left anyway. Python3 may fix the issue if its a unicode problem.
@Erotemic I have tried to remove the line:
COMMAND "${_python_exe}" -c "${_fixup_cmd}"
I got:
C:\Users\Administrator>cmake -P utils.cmake
CMake Warning (dev) at utils.cmake:75 (if):
if given arguments:
"TRUE"
An argument named "TRUE" appears in a conditional statement. Policy
CMP0012 is not set: if() recognizes numbers and boolean constants. Run
"cmake --help-policy CMP0012" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
This warning is for project developers. Use -Wno-dev to suppress it.
ERROR Failed to remove indentation from:
"""
from distutils import sysconfig
print(sysconfig.get_python_lib(prefix=''))
"""
Python dedent failed with error code: 系统找不到指定的文件。
CMake Error at utils.cmake:30 (message):
Python dedent failed with error code: 系统找不到指定的文件。
Call Stack (most recent call first):
utils.cmake:53 (dedent)
utils.cmake:96 (pycmd)
It seems the problem still exists..... When I try something you give:
execute_process(
COMMAND echo "${text}"
COMMAND "${_python_exe}" -c "print('hello_world')"
RESULT_VARIABLE _dedent_exitcode
OUTPUT_VARIABLE _dedent_text)
the output is still:
C:\Users\Administrator>cmake -P utils.cmake
CMake Warning (dev) at utils.cmake:76 (if):
if given arguments:
"TRUE"
An argument named "TRUE" appears in a conditional statement. Policy
CMP0012 is not set: if() recognizes numbers and boolean constants. Run
"cmake --help-policy CMP0012" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
This warning is for project developers. Use -Wno-dev to suppress it.
ERROR Failed to remove indentation from:
"""
from distutils import sysconfig
print(sysconfig.get_python_lib(prefix=''))
"""
Python dedent failed with error code: 系统找不到指定的文件。
CMake Error at utils.cmake:31 (message):
Python dedent failed with error code: 系统找不到指定的文件。
Call Stack (most recent call first):
utils.cmake:54 (dedent)
utils.cmake:97 (pycmd)
I find that code is used to remove indentation in python-Lib-sitepackages, is that true? I also try to run this in my python:
from distutils import sysconfig
print(sysconfig.get_python_lib(prefix=''))
I got :
>>> from distutils import sysconfig
>>> print(sysconfig.get_python_lib(prefix=''))
Lib\site-packages
And finally I change my python(from 2.7.14 to 3.6.4), it still can't work and it has the same error......now I’m lost myself..... Can this problem be solved? I think it will be many people who have the same problem, if he/she wants to install caffe2 in windows. I'm looking forward to your reply!
@Kasdision could you tell me how to solved the problem? I face the same problem....
When I try to run build_windows.bat, I change" -DBUILD_PYTHON=OFF^" to " -DBUILD_PYTHON=ON^", and then the bat is flashing and exit. Does anyone else has this problem? My computer enviroment is: win10/VS2015/python2.7.14/cuda9.0/cudnn7.1 Please help me, any assistance you could give will be greatly appreciated!
CMake summary output