Created
December 12, 2016 08:34
-
-
Save dbcooper/de7ac7b1f6b5bd42da5f14b167639bae to your computer and use it in GitHub Desktop.
Add Python directories to Windows command shell (cmd.exe)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @rem Base Python directory | |
| @set PythonPath=%USERPROFILE%\AppData\Local\Programs\Python\Python35 | |
| @REM I'm assuming command extensions are off and Perl is installed :\ | |
| @REM Make temporary directory to hold new path information, since I have to set it through an intermediate file? | |
| @cd %USERPROFILE% | |
| @if not exist tmp mkdir tmp | |
| @REM Add path(s) to environment path, keeping order but avoiding duplicates (I hope) | |
| @echo Adding python command directories to the current environment: | |
| @perl -e "my @ordered = split(/;/, $ENV{PATH}); push @ordered, @ARGV; for my $p (@ordered) { next if exists $u{$p}; $u{$p} = 1; push @clean, $p; } my $np = join q(;), @clean; print $np . qq(\n);" "%PythonPath%" "%PythonPath%\Scripts" > %USERPROFILE%\tmp\_newpath | |
| @set /P PATH=< %USERPROFILE%\tmp\_newpath | |
| @rem Not strictly necessary | |
| @echo %path% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment