Reputation: 8437
I have a Makefile with this target:
MY_DIR:=${CURDIR}/MY/DIR
my_proj:
cd $(MY_DIR); echo $(MY_ENV_VAR); python $(MY_ENV_VAR)/myscript.py --src $(MY_DIR) config
that runs a python script, i.e. myscript.py
that its location is stored in the MY_ENV_VAR
environment variable. The weird point is that the echo command, prints the variable correctly (i.e. c:/my/project/dir), but the python complains that it cannot find the script file with this error:
python.exe: can't open file 'c:myprojectdir/myscript.py': [Errno 2] No such file or directory
Now, the main Q is why the make tool interprets my environment variable correctly in the echo command, but the path is broken while passing to python?
p.s. I am working with python 3.7.3, make 4.2.1 on Windows 10.
Update 1: I have used the $(value ...)
function as described in some other questions and here, but the problem is still the same.
Upvotes: 0
Views: 136
Reputation: 326
From the information given it is hard to know. I would guess that perhaps you have c:\ instead of c:/ in that path and that the \ end up as an invalid escape character. Try using \\ in the path, or replacing it with a forward slash.
I can't test this myself though since I'm on Linux.
Upvotes: 3