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-985413409,https://api.github.com/repos/pydata/xarray/issues/5841,985413409,IC_kwDOAMm_X846vDch,14808389,2021-12-03T10:42:34Z,2021-12-03T10:42:34Z,MEMBER,"I don't think `xarray` has anything to do with that issue: if `python -c 'import dask'` succeeds, `xarray` will *have* to assume `dask` is available.
You will probably have to investigate `pip` (why didn't it remove the `__pycache__` directory?) or `pytest` (why was the `pyc` file created in the first place?) to really fix this, but for now you can try setting `PYTHONDONTWRITEBYTECODE` or running `python` with `-B` (for example, `python -B -m pytest`)","{""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
https://github.com/pydata/xarray/issues/5841#issuecomment-945186522,https://api.github.com/repos/pydata/xarray/issues/5841,945186522,IC_kwDOAMm_X844Vmba,5669557,2021-10-17T20:05:45Z,2021-10-17T20:05:45Z,NONE,"Hm, ok this seems to pass for me as well. I will have to look into it a bit
more, thanks for your advice.
On Sun, Oct 17, 2021 at 9:50 AM keewis ***@***.***> wrote:
> I still can't reproduce if I create the environment using
>
> python3.9 -m venv testsource test/bin/activate
> python -m pip install xarray
> python -c 'import xarray'
>
> Looking at the traceback you posted it seems you've been trying to install
> into /usr/local/lib/python3.9? That's something you should avoid as much
> as possible, unless you're trying to build OS packages.
>
> —
> You are receiving this because you modified the open/close state.
> Reply to this email directly, view it on GitHub
> , or
> unsubscribe
>
> .
>
","{""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-945157584,https://api.github.com/repos/pydata/xarray/issues/5841,945157584,IC_kwDOAMm_X844VfXQ,14808389,2021-10-17T16:50:05Z,2021-10-17T16:50:38Z,MEMBER,"I still can't reproduce if I create the environment using
```sh
python3.9 -m venv test
source test/bin/activate
python -m pip install xarray
python -c 'import xarray'
```
Looking at the traceback you posted it seems you've been trying to install into `/usr/local`? That's something you should avoid as much as possible (unless you're trying to build OS packages).","{""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-945153975,https://api.github.com/repos/pydata/xarray/issues/5841,945153975,IC_kwDOAMm_X844Vee3,5669557,2021-10-17T16:26:03Z,2021-10-17T16:26:03Z,NONE,"Thanks. Note I am using `venv`(not conda) on python 3.9.
So after creation of a clean environment and then `pip install xarray` I needed `pip install dask` to not see this error.","{""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-945112226,https://api.github.com/repos/pydata/xarray/issues/5841,945112226,IC_kwDOAMm_X844VUSi,14808389,2021-10-17T12:43:58Z,2021-10-17T12:43:58Z,MEMBER,"closing as a environment issue, but feel free to ask if you need more help","{""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-939267151,https://api.github.com/repos/pydata/xarray/issues/5841,939267151,IC_kwDOAMm_X843_BRP,14808389,2021-10-09T09:45:00Z,2021-10-09T09:46:13Z,MEMBER,"I don't think there is, unfortunately","{""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-937808678,https://api.github.com/repos/pydata/xarray/issues/5841,937808678,IC_kwDOAMm_X8435dMm,5669557,2021-10-07T13:45:55Z,2021-10-07T13:45:55Z,NONE,"Actually It doesn't seem to be so simple, I will try to isolate the issue n my installation. Is there any way to disable dask explicitly so I can bypass this error?","{""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-937771657,https://api.github.com/repos/pydata/xarray/issues/5841,937771657,IC_kwDOAMm_X8435UKJ,5669557,2021-10-07T13:03:40Z,2021-10-07T13:03:40Z,NONE,"Appreciate the help @keewis,
I did some investigative work and it seems to work fine until I install PyYAML.
","{""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-937532627,https://api.github.com/repos/pydata/xarray/issues/5841,937532627,IC_kwDOAMm_X8434ZzT,14808389,2021-10-07T07:35:22Z,2021-10-07T07:35:22Z,MEMBER,"that's strange, we even have a CI to make sure importing without having `dask` installed works. I also can't reproduce with
```bash
mamba create -n test python=3.9.7 # new clean environment
python -m pip install xarray
python -c 'import xarray as xr'
```
so maybe there's something wrong with your environment?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1019478260