html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue https://github.com/pydata/xarray/issues/5841#issuecomment-985473412,https://api.github.com/repos/pydata/xarray/issues/5841,985473412,IC_kwDOAMm_X846vSGE,9155111,2021-12-03T12:17:51Z,2021-12-03T12:33:59Z,CONTRIBUTOR,"See also #5236 which could be related which uses `conda`. I tried to scour through pip and pytest issues, but I can't find a discussion on this. `pip` and `pytest` and `pycache`are too generic keywords. I even found [pytest plugin to remove bytecode but it does not work ~~anymore~~ for me](https://pypi.org/project/pytest-remove-stale-bytecode/). I proposed a fix in #6039, which I believe is good to have, as you can't expect every user to execute with `python -B` or set `PYTHONDONTWRITEBYTECODE` while running tests.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1019478260 https://github.com/pydata/xarray/issues/5841#issuecomment-985386101,https://api.github.com/repos/pydata/xarray/issues/5841,985386101,IC_kwDOAMm_X846u8x1,9155111,2021-12-03T10:02:51Z,2021-12-03T10:02:51Z,CONTRIBUTOR,"This in my opinion is a cascade of multiple issues: - `pytest` creates special bytecode - `pip` does not clean the whole `__pycache__` directory on uninstall - `xarray.pycompat.is_duck_dask_array` uses `importlib.import_module('dask')` to determine if it is installed.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1019478260 https://github.com/pydata/xarray/issues/5841#issuecomment-985379668,https://api.github.com/repos/pydata/xarray/issues/5841,985379668,IC_kwDOAMm_X846u7NU,9155111,2021-12-03T09:53:46Z,2021-12-03T09:53:46Z,CONTRIBUTOR,"@twhughes @keewis In my case, I encounter this when I: - Have xarray + dask installed in my environment - Run any pytest which imports xarray (which in turn imports dask) - Uninstall dask, but pytest artefacts remain: ```sh ❯ ls venv/lib/python3.9/site-packages/dask/__pycache__ utils_test.cpython-39-pytest-6.2.5.pyc ``` Here are the steps which would *hopefully* reproduce the behaviour: ```py # Create this small unit test named: # test_import_xarray.py def test_xr(): import xarray ``` ```sh python -m venv venv source venv/bin/activate pip install xarray pytest dask pytest test_import_xarray.py pip uninstall dask ls venv/lib/python3.9/site-packages/dask/__pycache__ # See output above python -c 'import dask' # No ImportError! python -c 'import xarray' ``` Exact versions used Python 3.9.9 along with: ```sh # requirements.txt attrs==21.2.0 cloudpickle==2.0.0 dask==2021.11.2 fsspec==2021.11.1 iniconfig==1.1.1 locket==0.2.1 numpy==1.21.4 packaging==21.3 pandas==1.3.4 partd==1.2.0 pluggy==1.0.0 py==1.11.0 pyparsing==3.0.6 pytest==6.2.5 python-dateutil==2.8.2 pytz==2021.3 PyYAML==6.0 six==1.16.0 toml==0.10.2 toolz==0.11.2 xarray==0.20.1 ```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1019478260