Repository: conda/conda

Issue:
Win 10: Update to conda 4.4.4 breaks python path
I updated to conda 4.4.4 recently, and now when I open a new "Anaconda Prompt" the first thing that is displayed is:
`'python' is not recognized as an internal or external command,
operable program or batch file.`
At this point, I can start Python just fine. However, if I activate and then deactivate another environment, I can't use Python from the command prompt anymore. I get the same error message as above. I've tried rolling back the conda update with revisions, but that broke my installation. (The package pycosat does not get uninstalled properly, which seemed to break my conda install.)

Not sure if this matters, but the text in parentheses before the path has changed. Before the update, It would read as the path to my Anaconda installation. In conda 4.4.4, it reads as `(base)`. This may be intended for this update, but I just thought I would share. 


Discussion:
Do you know what version of conda you had before you updated?
I started with a fresh Anacoda distribution. (Py3.6, Win64)

Resolving patch:
diff --git a/conda/activate.py b/conda/activate.py
--- a/conda/activate.py
+++ b/conda/activate.py
@@ -266,6 +266,12 @@ def build_activate(self, env_name_or_prefix):
 
         self._update_prompt(set_vars, conda_prompt_modifier)
 
+        if on_win and self.shell == 'cmd.exe':
+            import ctypes
+            export_vars.update({
+                "PYTHONIOENCODING": ctypes.cdll.kernel32.GetACP(),
+            })
+
         return {
             'unset_vars': (),
             'set_vars': set_vars,


Test patch:
diff --git a/tests/test_activate.py b/tests/test_activate.py
--- a/tests/test_activate.py
+++ b/tests/test_activate.py
@@ -33,6 +33,13 @@
 log = getLogger(__name__)
 
 
+if on_win:
+    import ctypes
+    PYTHONIOENCODING = ctypes.cdll.kernel32.GetACP()
+else:
+    PYTHONIOENCODING = None
+
+
 class ActivatorUnitTests(TestCase):
 
     def test_activate_environment_not_found(self):
@@ -274,7 +281,6 @@ def test_activate_same_environment(self):
                         'CONDA_PROMPT_MODIFIER': "(%s) " % td,
                         'CONDA_SHLVL': 1,
                     }
-
                     assert builder['unset_vars'] == ()
                     assert builder['set_vars'] == {}
                     assert builder['export_vars'] == export_vars
@@ -478,6 +484,7 @@ def test_posix_basic(self):
                 'ps1': os.environ.get('PS1', ''),
             }
 
+    @pytest.mark.skipif(not on_win, reason="cmd.exe only on Windows")
     def test_cmd_exe_basic(self):
         activator = Activator('cmd.exe')
         self.make_dot_d_files(activator.script_extension)
@@ -500,6 +507,7 @@ def test_cmd_exe_basic(self):
         @SET "CONDA_PYTHON_EXE=%(sys_executable)s"
         @SET "CONDA_SHLVL=1"
         @SET "PATH=%(new_path)s"
+        @SET "PYTHONIOENCODING=%(PYTHONIOENCODING)s"
         @CALL "%(activate1)s"
         """) % {
             'converted_prefix': activator.path_conversion(self.prefix),
@@ -507,6 +515,7 @@ def test_cmd_exe_basic(self):
             'new_path': activator.pathsep_join(new_path_parts),
             'sys_executable': activator.path_conversion(sys.executable),
             'activate1': activator.path_conversion(join(self.prefix, 'etc', 'conda', 'activate.d', 'activate1.bat')),
+            'PYTHONIOENCODING': PYTHONIOENCODING,
         }
 
         with env_vars({