# Can I install pymc with pip on windows?

**URL:** <https://discourse.pymc.io/t/can-i-install-pymc-with-pip-on-windows/12813>\
**Category:** v5\
**Tags:** installation\
**Created:** [August 28, 2023, 7:27pm UTC](https://discourse.pymc.io/t/can-i-install-pymc-with-pip-on-windows/12813 "2023-08-28T19:27:13Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gabriella\_Chaos](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/gabriella_chaos/32/7022_2.png) [@Gabriella\_Chaos](https://discourse.pymc.io/u/Gabriella_Chaos)\
**Post date:** [August 28, 2023, 7:27pm UTC](https://discourse.pymc.io/t/can-i-install-pymc-with-pip-on-windows/12813/1 "2023-08-28T19:27:13Z")

</div>

I used to use pymc installed with pip on macos. I recently switch to windows system, and tries to get my environment together. I can get pymc installed with `pip install pymc`. However when I import it, I got following error: `UnicodeDecodeError: 'gbk' codec can't decode byte 0xba in position 2367: illegal multibyte sequence`. Anyone knows how to fix this?

Here is the entire traceback:

```auto
WARNING (pytensor.tensor.blas): Using NumPy C-API based implementation for BLAS functions.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\gabri\AppData\Roaming\Python\Python39\site-packages\pymc\ __init__.py", line 49, in <module>
    from pymc import _version, gp, ode, sampling
  File "C:\Users\gabri\AppData\Roaming\Python\Python39\site-packages\pymc\gp\ __init__.py", line 15, in <module>
    from pymc.gp import cov, mean, util
  File "C:\Users\gabri\AppData\Roaming\Python\Python39\site-packages\pymc\gp\util.py", line 30, in <module>
    from pymc.distributions.distribution import Distribution
  File "C:\Users\gabri\AppData\Roaming\Python\Python39\site-packages\pymc\distributions\ __init__.py", line 15, in <module>
    from pymc.distributions.bound import Bound
  File "C:\Users\gabri\AppData\Roaming\Python\Python39\site-packages\pymc\distributions\bound.py", line 23, in <module>
    from pymc.distributions.continuous import BoundedContinuous, bounded_cont_transform
  File "C:\Users\gabri\AppData\Roaming\Python\Python39\site-packages\pymc\distributions\continuous.py", line 59, in <module>
    from pymc.logprob.abstract import _logcdf_helper, _logprob_helper
  File "C:\Users\gabri\AppData\Roaming\Python\Python39\site-packages\pymc\logprob\ __init__.py", line 37, in <module>
    from pymc.logprob.basic import (
  File "C:\Users\gabri\AppData\Roaming\Python\Python39\site-packages\pymc\logprob\basic.py", line 65, in <module>
    from pymc.logprob.rewriting import cleanup_ir, construct_ir_fgraph
  File "C:\Users\gabri\AppData\Roaming\Python\Python39\site-packages\pymc\logprob\rewriting.py", line 84, in <module>
    from pymc.logprob.utils import DiracDelta, indices_from_subtensor
  File "C:\Users\gabri\AppData\Roaming\Python\Python39\site-packages\pymc\logprob\utils.py", line 67, in <module>
    from pymc.util import makeiter
  File "C:\Users\gabri\AppData\Roaming\Python\Python39\site-packages\pymc\util.py", line 20, in <module>
    import arviz
  File "C:\Users\gabri\AppData\Roaming\Python\Python39\site-packages\arviz\ __init__.py", line 33, in <module>
    from .data import *
  File "C:\Users\gabri\AppData\Roaming\Python\Python39\site-packages\arviz\data\ __init__.py", line 2, in <module>
    from .base import CoordSpec, DimSpec, dict_to_dataset, numpy_to_data_array
  File "C:\Users\gabri\AppData\Roaming\Python\Python39\site-packages\arviz\data\base.py", line 20, in <module>
    from .. import __version__ , utils
  File "C:\Users\gabri\AppData\Roaming\Python\Python39\site-packages\arviz\utils.py", line 667, in <module>
    class HtmlTemplate:
  File "C:\Users\gabri\AppData\Roaming\Python\Python39\site-packages\arviz\utils.py", line 692, in HtmlTemplate
    _, css_style = _load_static_files() # pylint: disable=protected-access
  File "C:\Users\gabri\AppData\Roaming\Python\Python39\site-packages\arviz\utils.py", line 662, in _load_static_files
    return [
  File "C:\Users\gabri\AppData\Roaming\Python\Python39\site-packages\arviz\utils.py", line 663, in <listcomp>
    importlib.resources.files("arviz").joinpath(fname).read_text() for fname in STATIC_FILES
  File "C:\Program Files\Python39\lib\pathlib.py", line 1257, in read_text
    return f.read()
UnicodeDecodeError: 'gbk' codec can't decode byte 0xba in position 2367: illegal multibyte sequence

```

---

<div class="post-metadata">

**Author:** ![cluhmann](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/cluhmann/32/3083_2.png) [@cluhmann](https://discourse.pymc.io/u/cluhmann)\
**Post date:** [August 28, 2023, 7:30pm UTC](https://discourse.pymc.io/t/can-i-install-pymc-with-pip-on-windows/12813/2 "2023-08-28T19:30:37Z")

</div>

The recommended installation procedure is [here](https://www.pymc.io/projects/docs/en/latest/installation.html). Pip is not recommended because it doesn’t offer all the compiled components (which is why you are getting the BLAS warning). So even if you weren’t getting the error you’re currently getting, sampling would be very slow.

---

<div class="post-metadata">

**Author:** ![Gabriella\_Chaos](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/gabriella_chaos/32/7022_2.png) [@Gabriella\_Chaos](https://discourse.pymc.io/u/Gabriella_Chaos)\
**Post date:** [August 28, 2023, 7:33pm UTC](https://discourse.pymc.io/t/can-i-install-pymc-with-pip-on-windows/12813/3 "2023-08-28T19:33:03Z")

</div>

Thanks for the quick reply! I see that the doc said installed through conda, but most of my packages are managed through pip right now. Is there any way I can retrieve all components through pip?

---

<div class="post-metadata">

**Author:** ![cluhmann](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/cluhmann/32/3083_2.png) [@cluhmann](https://discourse.pymc.io/u/cluhmann)\
**Post date:** [August 28, 2023, 7:39pm UTC](https://discourse.pymc.io/t/can-i-install-pymc-with-pip-on-windows/12813/4 "2023-08-28T19:39:06Z")

</div>

You can always install packages via pip when using conda-managed environments. See [here](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-pkgs.html#installing-non-conda-packages).

---

<div class="post-metadata">

**Author:** ![CynthiaLong](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/cynthialong/32/7141_2.png) [@CynthiaLong](https://discourse.pymc.io/u/CynthiaLong)\
**Post date:** [September 6, 2023, 3:00am UTC](https://discourse.pymc.io/t/can-i-install-pymc-with-pip-on-windows/12813/5 "2023-09-06T03:00:39Z")

</div>

Hi I just encountered the same error. Solved this by downgrading arviz.

```auto
mamba install -c conda-forge -n pymc_env arviz=0.15.1

```

I used mamba, you can use conda as well.

---

<div class="post-metadata">

**Author:** ![jeran.yang](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jeran.yang](https://discourse.pymc.io/u/jeran.yang)\
**Post date:** [November 15, 2023, 12:12pm UTC](https://discourse.pymc.io/t/can-i-install-pymc-with-pip-on-windows/12813/6 "2023-11-15T12:12:39Z")

</div>

I’ve tried this option. But it seems this problem has nothing to do with the arviz version. I directly changed the encoding to ‘utf-8’ and solved it.

---

<div class="post-metadata">

**Author:** ![jeran.yang](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jeran.yang](https://discourse.pymc.io/u/jeran.yang)\
**Post date:** [November 15, 2023, 12:14pm UTC](https://discourse.pymc.io/t/can-i-install-pymc-with-pip-on-windows/12813/7 "2023-11-15T12:14:41Z")

</div>

Go to the file of your last traceback and change the encoding by yourself.  
i.e. find the **pathlib.py** , go to **line 1257** , somewhere says [encoding=encoding], change it to [**encoding=‘utf-8’**]

---

<div class="post-metadata">

**Author:** ![Gabriella\_Chaos](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/gabriella_chaos/32/7022_2.png) [@Gabriella\_Chaos](https://discourse.pymc.io/u/Gabriella_Chaos)\
**Post date:** [December 15, 2023, 10:59pm UTC](https://discourse.pymc.io/t/can-i-install-pymc-with-pip-on-windows/12813/8 "2023-12-15T22:59:34Z")

</div>

I still get this problem even using conda to install.  
Following github issue seems related.

> <https://github.com/arviz-devs/arviz/issues/2274>
>
> Holle, I want to run:
> 
> \`\`\`python
> import arviz
> 
> the console return:
> File …~\\anaconda3\\lib\\site-packages\\spyder\_kernels\\py3compat.py:356 in compat\_exec
> exec(code, globals, locals)
> 
> File c:\\mypy\\hann-hydro\\ces.py:7
> import arviz as az
> 
> File ~\\anaconda3\\lib\\site-packages\\arviz\\\_\_init\_\_.py:33
> from .data import \*
> 
> File ~\\anaconda3\\lib\\site-packages\\arviz\\data\\\_\_init\_\_.py:2
> from .base import CoordSpec, DimSpec, dict\_to\_dataset, numpy\_to\_data\_array
> 
> File ~\\anaconda3\\lib\\site-packages\\arviz\\data\\base.py:20
> from .. import \_\_version\_\_, utils
> 
> File ~\\anaconda3\\lib\\site-packages\\arviz\\utils.py:666
> class HtmlTemplate:
> 
> File ~\\anaconda3\\lib\\site-packages\\arviz\\utils.py:691 in HtmlTemplate
> \_, css\_style = \_load\_static\_files() # pylint: disable=protected-access
> 
> File ~\\anaconda3\\lib\\site-packages\\arviz\\utils.py:663 in \_load\_static\_files
> return \[importlib.resources.files("arviz").joinpath(fname).read\_text() for fname in STATIC\_FILES\]
> 
> File ~\\anaconda3\\lib\\site-packages\\arviz\\utils.py:663 in \<listcomp\>
> return \[importlib.resources.files("arviz").joinpath(fname).read\_text() for fname in STATIC\_FILES\]
> 
> File ~\\anaconda3\\lib\\pathlib.py:1135 in read\_text
> return f.read()
> 
> UnicodeDecodeError: 'gbk' codec can't decode byte 0xba in position 2367: illegal multibyte sequence
> \`\`\`
> 
> What do I need to do to solve this problem? Looking forward to your answer！

---

<div class="post-metadata">

**Author:** ![Gabriella\_Chaos](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/gabriella_chaos/32/7022_2.png) [@Gabriella\_Chaos](https://discourse.pymc.io/u/Gabriella_Chaos)\
**Post date:** [December 16, 2023, 2:25am UTC](https://discourse.pymc.io/t/can-i-install-pymc-with-pip-on-windows/12813/9 "2023-12-16T02:25:24Z")

</div>

Instead of modifying pathlib, i feel it is better to change util.py in arviz directory （`Lib\site-packages\arviz\utils.py`). Change line 663 to:

```auto
importlib.resources.files("arviz").joinpath(fname).read_text(encoding='utf-8') for fname in STATIC_FILES

```

i.e. add encoding=‘utf-8’ in the parenthesis would work.

---

<div class="post-metadata">

**Author:** ![cluhmann](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/cluhmann/32/3083_2.png) [@cluhmann](https://discourse.pymc.io/u/cluhmann)\
**Post date:** [December 18, 2023, 8:23pm UTC](https://discourse.pymc.io/t/can-i-install-pymc-with-pip-on-windows/12813/10 "2023-12-18T20:23:15Z")

</div>

That appears to be the most recent comment on [the relevant arviz issue](https://github.com/arviz-devs/arviz/issues/2274).
