Getting a Working Pymc3 Windows 10 Installation using Anaconda - An Installation Guide

I’m a user of Pymc3 on Windows 10 using Anaconda and for the longest time that I can remember, it has been incredibly frustrating to get Pymc3 working correctly. Often this was due to the lack of consistent compilers being available on Windows. When they were available, say via Anaconda or Cygwin or Mingw or MSYS2, configuration was a nightmare. Or a working install would break with package upgrades!!! My instructions are geared towards a beginner/intermediate level user in setting up these tools and environments on Windows. Assumes you will not try to fix an existing installation of Pymc3. Assumes you are going to do a fresh install. - Assumes you know the risk of playing with open-source tools

Here are the set of instructions that worked for me in getting Pymc3 working on Windows 10 and Anaconda.

Setting up Compilers using MSYS2 (current 11.2.0)

  1. Download MSYS2 from here MSYS2 and follow the instructions exactly as given.

  2. Once installation and post installation activities are completed do the following (You may need Admin level rights) - Search for Edit System Environment Variables. In the GUI interface,

  3. Click on “Environment Variables” button


  1. In the top part of the window meant for “User Variables” select “path” and then click on “Edit” button. You should see:

  2. Click on “New” button. Add the path “C:\msys64\mingw64\bin” and move it to the top.

  3. Next add the path “C:\msys64\usr\bin” and move it just under the previous path. Path in step 5 should be 1 and path in step 6 should be 2.

Note - Do not make this change in the System Variables. Make it only in the User Variable and I will explain why. If you are a R user like I’m using both R and Python for advanced analytics, making these changes in System Variables will mess up detection of your RTools by R/R-Studio. Hence you see that under my User Variables there is a “RTOOLS40_HOME” variable. RTools is also based on MSYS2 with gcc-8.3.0 version. Pymc3 will not work correctly with this version. You notice RTools location in not in the Users Path variable but under a separate User Variable

** Download and Install Anaconda **

  1. Launch the Anaconda3 CMD Prompt. You should see:
(base) C:\Users\Your_User_Name>
  1. Run the command g++ --version at the previous prompt - If you have installed MSYS2 and set up user variables correctly then your output should look like:
Using built-in specs.
Target: x86_64-w64-mingw32
Configured with: ../gcc-11.2.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include --libexecdir=/mingw64/lib --enable-bootstrap --enable-checking=release --with-arch=x86-64 --with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++,jit --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts --enable-libstdcxx-time --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-lto --enable-libgomp --disable-multilib --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev2, Built by MSYS2 project' --with-bugurl= --with-gnu-as --with-gnu-ld --with-boot-ldflags='-pipe -Wl,--dynamicbase,--high-entropy-va,--nxcompat,--default-image-base-high -Wl,--disable-dynamicbase -static-libstdc++ -static-libgcc' 'LDFLAGS_FOR_TARGET=-pipe -Wl,--dynamicbase,--high-entropy-va,--nxcompat,--default-image-base-high' --enable-linker-plugin-flags='LDFLAGS=-static-libstdc++\ -static-libgcc\ -pipe\ -Wl,--dynamicbase,--high-entropy-va,--nxcompat,--default-image-base-high\ -Wl,--stack,12582912'
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.0 (Rev2, Built by MSYS2 project)
  1. If you do not see this output with 11.2.0 version of gcc you have to go to your MSYS2 and User Variable setup.

Assuming your test shows gcc-11.2.0 proceed to create a new environment and install pymc3 using the following commands

** Pymc3 installation **

  1. Do not install pymc3 in the base environment. Create a new environment using
(base) C:\Users\Your_User_Name>conda create -n pymc3_env -c conda-forge python libpython mkl-service numba python-graphviz scipy arviz

Key pieces of the installation are taken from Pymc3 Installation Guide (Windows)
here pymc3_env is the new environment being created (you can use a name of your choice). If all goes well you should see this output

Preparing transaction: done
Verifying transaction: done
Executing transaction: done
# To activate this environment, use
#     $ conda activate pymc3_env
# To deactivate an active environment, use
#     $ conda deactivate
  1. Activate the new environment
(base) C:\Users\Your_User_Name>conda activate pymc3_env
  1. Your new prompt should look like:
(pymc3_env) C:\Users\Your_User_Name>
  1. Next run the command pip install pymc3 at the prompt

  2. There should be no errors and you should see at the very end the following message:

Installing collected packages: filelock, theano-pymc, semver, patsy, fastprogress, dill, cachetools, pymc3
Successfully installed cachetools-5.0.0 dill-0.3.4 fastprogress-1.0.0 filelock-3.4.2 patsy-0.5.2 pymc3-3.11.4 semver-2.13.0 theano-pymc-1.1.2

Make sure that this above message includes theano-pymc and not theano. Your pymc3 will not work correctly if theano exists in your environment. It also means you are not installing into a fresh environment.

** Testing that Pymc3 Works **

  1. At the pymc3_env prompt, launch python shell by running the command python
(pymc3_env) C:\Users\Your_User_Name>python
  1. You should see:
Python 3.10.2 | packaged by conda-forge | (main, Jan 14 2022, 07:58:58) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
  1. Type the following commands one at a time and check you can run without any errors
    a. >>>import numpy as np
    b. >>>import pymc3 as pm
    c. >>>import theano

d. >>>d = pm.Normal.dist(mu=0, sd=1) (defining an instance of Normal Dist using pymc3 pm)
e. >>>d.dist() (confirming the type of variable/object created)
<pymc3.distributions.continuous.Normal object at 0x0000027EE8043700> [output]

f. >>>d.random(size=10) (drawing a sample of 10 values from the created distribution)
array([-0.73922894, 1.36053095, 1.06533255, 2.64590712, 1.24948074,
-0.82108831, -1.42403241, -1.16401114, -0.14718495, -0.37357477])
(Note - you will get different values from what I show since these are draws from a Normal Distribution)

g. >>>d.logp(0).eval() (calculating the Log Probability of the distribution)

(Note - The log probability should be the same as the value shown above since this is a Standard Normal Distribution)

  1. If you are able to get all the commands to run correctly then you know your Pymc3 is working correctly.

  2. You can exit this python shell with exit() command.

  3. Your prompt should look like:

(pymc3_env) C:\Users\Your_User_Name>
  1. If you prefer to use either Jupyter Notebooks or Jupyter Lab for your pymc3 example projects you can additionally install using
(pymc3_env) C:\Users\Your_User_Name>conda install -c conda-forge notebook
  1. This command once run will install a whole lot of new packages. Once you get the prompt back you can run the command jupyter-notebook and it should launch in your default browser. You can get additional examples to run from the following extensive resources:

  2. Getting Started with Pymc3

  3. Tutorials

  4. Examples

** Feedback and Q&A **

  1. Just knowing how difficult and frustrating such a setup can be for Windows users, if you have questions or running into trouble with these instructions on a fresh installation and setup of Pymc3 on Windows, I will try my best to help and troubleshoot.

  2. Hopefully you are trying all these things on a personal machine and not a mission critical work machine.

  3. You are working with Open-source tools and Windows does not play nice with them and with the next upgrade of Windows or next version of Anaconda or next version of Pymc3 or your gcc tool or some other obscure package dependency, your Pymc3 install can and will break.

  4. I owe an incredible number of thanks to all those folks here and the Pymc3 github site for the amazingly patient help they have extended over the years to users such as I. Thanks all!


I wanted to make sure that Pymc3 users with a bit more advanced skills in programming / compilers and such can follow some more alternatives that have been pursued to make the default gcc 5.3.0 compilers work on Windows 10. This is a long thread but definitely worth a read to delve deeper into the compilers issues that have been difficult to overcome. See this link below:

Windows 10 - Pymc3 - GCC Compilers

See particularly the more recent developments by @jedludlow and the results from some of the testing I had done with this experimental version of pymc3 which works with the default gcc-5.3.0 installed with mingw toolchain.

1 Like

I recently started learning Pymc3 to use it in my research as this is a flexible and useful probabilistic programming package for solving real-world problems.

However, I could not install correctly and run this package and I received several warnings and errors when I was trying to run Pymc3.

I followed many instructions that have been posted (to install Pymc3 on windows) on different web pages, but they did not work. When I asked my questions about the warnings and errors, I was referred to this article.

I followed these instructions step by step, and gratefully I was able to successfully install and run Pymc3.

Please share this article with people who want to install and run Pymc3. This saves their time considerably as it took me several months to finally install and run Pymc3.

Thank you @sree_datta for these detailed instructions.

1 Like

Glad to know you now have a working installation of Pymc3. Thanks for the feedback @Majid-Eskafi - so many of the users and developers of Pymc3 have been instrumental in the development of these instructions. Happy learning!!

1 Like

First of all, thanks a TON for these detailed step-by-step instructions to install arguably one of the most difficult packages to install on Windows.
It seems these steps worked for you and several others at the time (~ 3months ago).
Just today, i replicated the steps exactly, but got stuck at installing pymc3 using pip inside the conda environment.
when i run pip install pymc3 i get:
ERROR: Could not find a version that satisfies the requirement pymc3 (from versions: none)
ERROR: No matching distribution found for pymc3

I have Windows 10 X64
MSYS2 installed with g++ version 11.3.0 (paths added to top of user environment variables as indicated in instructions)
Anaconda3 2021.11 with python 3.9.7 bundled within
pymc_env environment created with python version 3.10.4 (that is what is picked up by conda-forge channel when environment was created).

Would you know if there is anything i might be missing here ? Could it be related to your 3rd question above in Q&A on version conflicts during upgrades by Anaconda, python , g++ etc. ?

Thank you ,

1 Like

Well, it turns out my pip installation in conda was corrupted. I uninstalled everything and started over. It is working great now !.
Thanks again for sharing these instructions


@Yasser_Elbissaty thanks for sharing your experience with the instructions. I’m happy to see you were able to resolve the error too. Your experience is another testament to the dynamics of working with open source tools in Windows.

1 Like

Thank you @sree_datta. I agree with you, open source gives us endless freedom to getting creative but also comes with challenges.
Like you , I use R/Rstan/Brms mainly when it comes to Bayesian modeling, but wanted to have both Rstan and Pymc living nicely together on my windows computer.
I don’t recall having issues with setting up Rstan as Rtools is pretty packaged nicely for windows, unlike pymc3.
There is also Pyro built on top of PyTorch, and I didn’t have issues installing it, but i find it more involved and not as easy to include in projects pipelines

1 Like

@am889 I was able to help one of the users of pymc via a Zoom call. If you have the time I could help you the same way. Let me know if you are unable to resolve the error

1 Like


Thanks for getting back to me. A zoom call might be worthwhile (for me!). I’ve had to uninstall everything and reinstall all my R stuff fresh to restore functionality. I currently don’t have any python going. After prowling the Google help groups associated with the specific modeling module I need to use (hddm), it seems that it just doesn’t work well on Windows. Most responses to others with similar(ish) problems are along the lines of ‘learn to use docker’ or install a bunch of older versions of things.

Critically, none of them speak to maintaining separate R and Python functionality with respect to their separate compilers, etc.

Don’t know if that’s something you really feel like taking time to work through…

Best wishes,

@am889 by helping you I might end up learning some thing new so I’m always up for it. I’m concerned about your time line for getting this working. I’m in US EST. Where are you based? Accordingly I can set up a time for us to meet via Zoom. Send me a detailed note on what you tried and what problem(s) you ran into. All the best!

1 Like

@sree_datta Thanks again, but I got it fixed. Not 100% sure what happened, but both R + rstan and Python + hddm are up and running without interference. I suspect that part of the problem was the Windows Security settings.


@Yasser_Elbissaty thanks Yasser for sharing your feedback and your experience with pymc. I have been slowly working with pytorch. I will probably share a comparison on the two libraries once I feel comfortable with both