I have bat file named data.bat with simple command "python". When i double click the bat file python is running successfully. But when i run the bat file from MATLAB using the commands below,
dos('C:\Users\W25VCSQ\Desktop\data.bat &') or system('data.bat')
I am getting the error "The command python is either false or not found"
How should i call the bat file or how should the bat file should be written?
Thanks a lot

댓글 수: 5

Stephen23
Stephen23 2017년 6월 26일
@Gopalakrishnan venkatesan: please show us the complete error message. This means all of the red text.
Gopalakrishnan venkatesan
Gopalakrishnan venkatesan 2017년 6월 26일
'C:\Program' is not recognized as an internal or external command, operable program or batch file.
dpb
dpb 2017년 6월 26일
편집: dpb 2017년 6월 26일
That has no string in common with any of the above...
We need to see a full session sequence in context and in its entirety directly cut 'n pasted from the command window as well as the content of the .bat file.
NB: File names with embedded blanks as in
C:\Program Files\...
must be surrounded with "
It looks like your case may not be and the first portion of the string is being interpreted as the /C option by CMD
Gopalakrishnan venkatesan
Gopalakrishnan venkatesan 2017년 6월 26일
I have attached the content of the batch file in txt format.
dpb
dpb 2017년 6월 26일
편집: dpb 2017년 6월 26일
OK, but not the full context from Matlab--only a bit at a time that we can't see the whole problem from.
Again, a piece of code with all variables in it defined executed and then the error message all in one complete piece.
Also, you can execute
system &
and then check what are the environment variables (particularly PATH) and whether
python
at that command prompt will run/be found or not. If not, you need to either use fully-qualified path to the executable or execute a PATH= command first in the .bat file to set the PATH as needed for the session.

댓글을 달려면 로그인하십시오.

 채택된 답변

dpb
dpb 2017년 6월 26일

0 개 추천

When the new process is spawned, it inherits default environment (PATH and other variables). If python isn't installed on that default path, it won't be found. Have the .bat file set any environment variables it needs or modify the startup environment to make that a global setting all sessions will inherit. The former is probably the more appropriate rather than modifying system.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

질문:

2017년 6월 26일

편집:

dpb
2017년 6월 26일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by