" %HAS_PLACEHOLDER% " = "True " REM If it did, replace it with our NEW_PATH REM Delayed expansion used here to do replacement with value of NEW_PATH SET " PATH = %%PATH:CONDA_PATH_PLACEHOLDER= !NEW_PATH! %% " SET " PROMPT =( %CONDA_NEW_ENV%) %PROMPT% REM always store the full path to the environment, since CONDA_DEFAULT_ENV varies /F "tokens=1 delims= " %%i in ( " %NEW_PATH% ") DO SET " CONDA_PREFIX = %%i " REM Do we have CONDA_PATH_PLACEHOLDER in PATH? SET " CHECK_PLACEHOLDER =import os print('CONDA_PATH_PLACEHOLDER' in os.environ) " /F "tokens=1 delims= " %%i in (' " %~dp0\.\python " -c " %CHECK_PLACEHOLDER% "') DO SET " HAS_PLACEHOLDER = %%i " REM look if the deactivate script left a placeholder for us. changeps1') DO SET " CHANGE_PROMPT = %%i " errorlevel 1 exit /b 1 :: if our prompt var does not contain reference to CONDA_DEFAULT_ENV, set prompt " %CHANGE_PROMPT% " = "1 " "x %PROMPT: CONDA_DEFAULT_ENV=% " = "x %PROMPT% " ( current path followed by greater sign NOT DEFINED PROMPT SET PROMPT SET " CONDA_PS1_BACKUP = %PROMPT% " /F "delims= " %%i IN (' " %CONDA_EXE% ". activate "cmd.exe " " %CONDA_NEW_ENV% "') DO SET " NEW_PATH = %%i " errorlevel 1 exit /b 1 REM take a snapshot of pristine state for later REM if PROMPT is not set at all, explicitly set it to the default, i.e. checkenv "cmd.exe " " %CONDA_NEW_ENV% " errorlevel 1 exit /b 1 REM The argument here tells the deactivate script to leave a placeholder for us when it removes PATH entries, REM so that we can put our new path entries back in the same place " %~dp0\deactivate.bat " "hold " errorlevel 1 exit /b 1 REM Activate the new environment /F "delims= " %%i IN (' " %CONDA_EXE% ". : skipmissingarg REM Ensure that path or name passed is valid before deactivating anything " %CONDA_EXE% ". ![]() : skiptoomanyargs not " %~1 " = " " REM Set env to root if no arg provided set CONDA_NEW_ENV =root ( echo Error: did not expect more than one argument.) 1 >&2 :: reset errorlevel to 0 cmd /c "exit /b 0 " %~2 " = " " skiptoomanyargs setlocal enabledelayedexpansion /F "delims= " %%i IN (' " %~dp0.\python.exe " -c "import ctypes print(()) "') DO SET " PYTHONIOENCODING = %%i " chcp !PYTHONIOENCODING! > NUL set " CONDA_NEW_ENV = %~1 " SET " CONDA_EXE = %~dp0\.\Scripts\conda.exe " :: this finds either -help or -h and shows the help text ECHO " %~1 " | %SystemRoot%\System32\find.exe /I "-h " 1 > NUL NOT ERRORLEVEL 1 " %CONDA_EXE% ". REM For debugging, remove the on the section you need to study. REM Setting it this way allows us to not touch the user's echo setting. ^^^ The above line should NO LONGER be in your ~/.bash_profile file! ^^^Ĭhanging the above fixed my issues with sys.path in activated conda environments.REM symbols in this file indicate that output should not be printed. You should manually remove the line that looks like Previous to conda 4.4, the recommended way to activate conda was to modify PATH in $ echo "conda activate" > ~/.bash_profile In your terminal, or to put the base environment on PATH permanently, run Put conda's base (root) environment on PATH. The options above will permanently enable the 'conda' command, but they do NOT $ sudo ln -s ~/anaconda/etc/profile.d/conda.sh /etc/profile.d/conda.sh ~/anaconda/etc/profile.d/conda.sh" > ~/.bash_profile If your shell is Bash or a Bourne variant, enable conda for the current user with ![]() ![]() Indeed, if you upgrade from an older version of conda and you try the above, you may see the following helpful message (which I did): CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'. Thus, the new way to activate/deactivate environments is to do it like the above. ![]() # To deactivate an active environment, use My sys.path was not correct for a bit until I figured out way.Īs a result, I want to point out for anyone else confused by a change in conda, that if you have upgraded conda and created an environment, it will now tell you (as opposed to previous behavior): # To activate this environment, use I just created a new environment with conda and things are different.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |