Repository: conda/conda

Issue:
conda pip interop AssertionError in 4.6.1
This is the error with the most reports for 4.6.1 (over 100 in the last 24 hours).  I've got a PR in the works to resolve this one.

```
error: AssertionError()
command: D:\Users\rahul\Anaconda3\Scripts\conda-script.py list
user_agent: conda/4.6.1 requests/2.18.4 CPython/3.6.5 Windows/10 Windows/10.0.17763
_messageid: -9223372036617369010
_messagetime: 1548792058544 / 2019-01-29 14:00:58

Traceback (most recent call last):
  File "D:\Users\rahul\Anaconda3\lib\site-packages\conda\exceptions.py", line 1001, in __call__
    return func(*args, **kwargs)
  File "D:\Users\rahul\Anaconda3\lib\site-packages\conda\cli\main.py", line 84, in _main
    exit_code = do_call(args, p)
  File "D:\Users\rahul\Anaconda3\lib\site-packages\conda\cli\conda_argparse.py", line 81, in do_call
    exit_code = getattr(module, func_name)(args, parser)
  File "D:\Users\rahul\Anaconda3\lib\site-packages\conda\cli\main_list.py", line 142, in execute
    show_channel_urls=context.show_channel_urls)
  File "D:\Users\rahul\Anaconda3\lib\site-packages\conda\cli\main_list.py", line 80, in print_packages
    show_channel_urls=show_channel_urls)
  File "D:\Users\rahul\Anaconda3\lib\site-packages\conda\cli\main_list.py", line 45, in list_packages
    installed = sorted(PrefixData(prefix, pip_interop_enabled=True).iter_records(),
  File "D:\Users\rahul\Anaconda3\lib\site-packages\conda\core\prefix_data.py", line 116, in iter_records
    return itervalues(self._prefix_records)
  File "D:\Users\rahul\Anaconda3\lib\site-packages\conda\core\prefix_data.py", line 145, in _prefix_records
    return self.__prefix_records or self.load() or self.__prefix_records
  File "D:\Users\rahul\Anaconda3\lib\site-packages\conda\core\prefix_data.py", line 69, in load
    self._load_site_packages()
  File "D:\Users\rahul\Anaconda3\lib\site-packages\conda\core\prefix_data.py", line 258, in _load_site_packages
    python_record = read_python_record(self.prefix_path, af, python_pkg_record.version)
  File "D:\Users\rahul\Anaconda3\lib\site-packages\conda\gateways\disk\read.py", line 245, in read_python_record
    pydist = PythonDistribution.init(prefix_path, anchor_file, python_version)
  File "D:\Users\rahul\Anaconda3\lib\site-packages\conda\common\pkg_formats\python.py", line 78, in init
    return PythonInstalledDistribution(prefix_path, anchor_file, python_version)
  File "D:\Users\rahul\Anaconda3\lib\site-packages\conda\common\pkg_formats\python.py", line 382, in __init__
    super(PythonInstalledDistribution, self).__init__(anchor_full_path, python_version)
  File "D:\Users\rahul\Anaconda3\lib\site-packages\conda\common\pkg_formats\python.py", line 106, in __init__
    self._check_files()
  File "D:\Users\rahul\Anaconda3\lib\site-packages\conda\common\pkg_formats\python.py", line 116, in _check_files
    assert isfile(fpath)
AssertionError
```


Discussion:

Resolving patch:
diff --git a/conda/common/pkg_formats/python.py b/conda/common/pkg_formats/python.py
--- a/conda/common/pkg_formats/python.py
+++ b/conda/common/pkg_formats/python.py
@@ -113,7 +113,8 @@ def _check_files(self):
         for fname in self.MANDATORY_FILES:
             if self._metadata_dir_full_path:
                 fpath = join(self._metadata_dir_full_path, fname)
-                assert isfile(fpath)
+                if not isfile(fpath):
+                    raise OSError(ENOENT, strerror(ENOENT), fpath)
 
     def _check_path_data(self, path, checksum, size):
         """Normalizes record data content and format."""
diff --git a/conda/core/prefix_data.py b/conda/core/prefix_data.py
--- a/conda/core/prefix_data.py
+++ b/conda/core/prefix_data.py
@@ -256,7 +256,8 @@ def _load_site_packages(self):
         for af in non_conda_anchor_files:
             try:
                 python_record = read_python_record(self.prefix_path, af, python_pkg_record.version)
-            except EnvironmentError:
+            except EnvironmentError as e:
+                log.info("Python record ignored for anchor path '%s'\n  due to %s", af, e)
                 continue
             except ValidationError:
                 import sys


Test patch:
diff --git a/tests/common/pkg_formats/test_python.py b/tests/common/pkg_formats/test_python.py
--- a/tests/common/pkg_formats/test_python.py
+++ b/tests/common/pkg_formats/test_python.py
@@ -5,6 +5,7 @@
 from __future__ import absolute_import, division, print_function, unicode_literals
 
 from datetime import datetime
+from errno import ENOENT
 import os
 from os.path import basename, lexists
 from pprint import pprint
@@ -523,8 +524,9 @@ def test_pydist_check_files():
 
     # Test mandatory file not found
     os.remove(fpaths[0])
-    with pytest.raises(AssertionError):
+    with pytest.raises(EnvironmentError) as exc:
         PythonInstalledDistribution(temp_path, "2.7", None)
+    assert exc.value.errno == ENOENT
 
 
 def test_python_dist_info():