Windows命令行替代Linux/Unix下export命令的机器学习环境搭建咨询
Windows Equivalent for Linux/Unix ML Environment Setup Commands
Hey there! I get it—those Linux commands work smoothly, but when you're on Windows, you need to tweak things a bit. Let's break down the equivalent steps for both Command Prompt (CMD) and PowerShell, since those are the most common shells you'll use on Windows.
Command Prompt (CMD)
Temporary Environment Variable (only active in current CMD window)
- Set the
ML_PATHvariable:set ML_PATH=%USERPROFILE%\ml - Create the directory (the
-pflag in Linux means create parent directories if needed, andmkdirin CMD handles this automatically):
You can also usemkdir %ML_PATH%md %ML_PATH%as a shorter alternative tomkdir.
Permanent Environment Variable (requires admin rights for system-wide setting)
- For user-level (only applies to your account):
setx ML_PATH "%USERPROFILE%\ml" - For system-level (applies to all users, needs admin privileges):
setx ML_PATH "%USERPROFILE%\ml" /M
Note: After setting permanently, you'll need to close and reopen your CMD window (or restart your PC) for the changes to take effect.
PowerShell
Temporary Environment Variable (only active in current PowerShell session)
- Set the
ML_PATHvariable:$env:ML_PATH = "$HOME/ml" - Create the directory with the same "create parent directories if missing" behavior as
mkdir -p:New-Item -ItemType Directory -Path $env:ML_PATH -Force
Permanent Environment Variable
- For user-level (no admin needed):
[Environment]::SetEnvironmentVariable("ML_PATH", "$HOME/ml", "User") - For system-level (requires admin rights):
[Environment]::SetEnvironmentVariable("ML_PATH", "$HOME/ml", "Machine")
Just like with CMD, you'll need to restart PowerShell or refresh your environment variables (you can run refreshenv if you have Chocolatey installed) to see the permanent changes.
内容的提问来源于stack exchange,提问作者Seth
相关产品推荐
相关产品推荐

