I'm facing a basic and stupid problem on Windows PowerShell. I'm almost sure it has already been answered somewhere but I can't find something working for me.
I simply would like to use a variable inside a command in PowerShell:
$VENV_DIR='C:\venv\'
python -m venv $VENV_DIR
$VENV_DIR\Scripts\python.exe --version
I expect to see Python 3.10.8
as result.
But I have this error:
PS C:\> $VENV_DIR\Scripts\python.exe --version
At line:1 char:10
+ $VENV_DIR\Scripts\python.exe --version
+ ~~~~~~~~~~~~~~~~~~~
Unexpected token '\Scripts\python.exe' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErr
orRecordException
+ FullyQualifiedErrorId : UnexpectedToken
I tried a lot of different combinations, but none of them work
97 $VENV_DIR\Scripts\python.exe --version
98 `$VENV_DIR\Scripts\python.exe --version
99 $VENV_DIR\\Scripts\python.exe --version
100 $VENV_DIR\Scripts\python.exe --version
101 "$VENV_DIR"\Scripts\python.exe --version
102 "$VENV_DIR\Scripts\python.exe" --version
103 "$VENV_DIR\Scripts\python.exe --version"
104 ("$VENV_DIR\Scripts\python.exe --version")
105 $("$VENV_DIR\Scripts\python.exe --version")
106 -$("$VENV_DIR\Scripts\python.exe --version")
107 -$("$VENV_DIR")\Scripts\python.exe --version
108 -$($VENV_DIR)\Scripts\python.exe --version
109 $VENV_DIR\Scripts\python.exe --version
110 (echo $VENV_DIR)\Scripts\python.exe --version
111 echo $VENV_DIR\Scripts\python.exe --version
112 $(echo $VENV_DIR)\Scripts\python.exe --version
113 -$(echo $VENV_DIR)\Scripts\python.exe --version
114 -$("echo $VENV_DIR")\Scripts\python.exe --version
115 echo $VENV_DIR\Scripts\python.exe --version
Could you please help? Thanks