# @lucianopaz。Please help me solve the Windows multiprocessing issue

**URL:** <https://discourse.pymc.io/t/lucianopaz-please-help-me-solve-the-windows-multiprocessing-issue/2327>\
**Category:** Questions\
**Created:** [December 5, 2018, 10:34am UTC](https://discourse.pymc.io/t/lucianopaz-please-help-me-solve-the-windows-multiprocessing-issue/2327 "2018-12-05T10:34:08Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abraxas2071](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/abraxas2071/32/1287_2.png) [@Abraxas2071](https://discourse.pymc.io/u/Abraxas2071)\
**Post date:** [December 5, 2018, 10:34am UTC](https://discourse.pymc.io/t/lucianopaz-please-help-me-solve-the-windows-multiprocessing-issue/2327/1 "2018-12-05T10:34:08Z")

</div>

@lucianopaz  
Pymc3’s charioteer， Bayesian’s faithful follower，and Sickness’s fighter，Our Dear Luciano， Glory to you！

Please save me from Windows10。✧⁺⸜(●˙▾˙●)⸝⁺✧

 ![1](https://canada1.discourse-cdn.com/flex036/uploads/pymc3/original/2X/e/ea522f04708882f7e3acb1e56cfe0192aafb74be.jpeg) ![2](https://canada1.discourse-cdn.com/flex036/uploads/pymc3/original/2X/1/1e3789b27bc4cf5eb629d421d2a8f0ab5ef6d902.jpeg)

---

<div class="post-metadata">

**Author:** ![lucianopaz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/lucianopaz/32/2186_2.png) [@lucianopaz](https://discourse.pymc.io/u/lucianopaz)\
**Post date:** [December 5, 2018, 11:06am UTC](https://discourse.pymc.io/t/lucianopaz-please-help-me-solve-the-windows-multiprocessing-issue/2327/2 "2018-12-05T11:06:37Z")

</div>

@Abraxas2071, the images with the traceback are a nice and all but they don’t give me much context. I can see that you get the typical Broken Pipe Error that happens in windows when you try to sample with more than 1 core, and something goes wrong while the worker process are being spawned.

This problem happens a lot on windows and the cause of the problems are really diverse and depend much on how you are running your script. Are you running an interactive IPython session? Are you running the code from inside the spyder IDE? Are you running it from a windows Command Prompt?

To allow me to help you, you have to copy here the code that you ran and raised the error you pasted above. I would need a [minimum working example](https://stackoverflow.com/help/mcve) to see what is going on.

Nevertheless, your traceback is showing an exception before the Broken Pipe, which could be the error that happened while the child process was being spawned. It looks like an unpickling error, as if some op cannot get compiled while it is being unpacked. Again, for me to be able to help you with this, add a minimum working example of the code. I would greatly appreciate if you could write it down using [markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code), that way I can see it here well formatted and can copy easily.

---

<div class="post-metadata">

**Author:** ![Abraxas2071](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/abraxas2071/32/1287_2.png) [@Abraxas2071](https://discourse.pymc.io/u/Abraxas2071)\
**Post date:** [December 5, 2018, 11:39am UTC](https://discourse.pymc.io/t/lucianopaz-please-help-me-solve-the-windows-multiprocessing-issue/2327/3 "2018-12-05T11:39:37Z")

</div>

@lucianopaz  
Pymc3’s charioteer， Bayesian’s faithful follower，and Sickness’s fighter，Our Dear Luciano， Glory to you！

I don’t know how to use markdown…  
Code is here:

```
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats
# import seaborn as sns
import pymc3 as pm
import pandas as pd

N = 100
alpha_real = 2.5
beta_real = [0.9, 1.5]
eps_real = np.random.normal(0, 0.5, size=N)

X = np.array([np.random.normal(i, j, N) for i, j in zip([10, 2], [1, 1.5])])
X_mean = X.mean(axis=1, keepdims=True)
X_centered = (X - X.mean()) # / X.std(ddof=1)
y = alpha_real + np.dot(beta_real, X) + eps_real

if __name__ == ' __main__':
    with pm.Model() as model_mlr:
        alpha_tmp = pm.Normal('alpha_tmp', mu=0, sd=10)
        beta = pm.Normal('beta', mu=0, sd=1, shape=2)
        epsilon = pm.HalfCauchy('epsilon', 5)

        mu = alpha_tmp + pm.math.dot(beta, X_centered)

        alpha = pm.Deterministic('alpha', alpha_tmp - pm.math.dot(beta, X_mean))

        y_pred = pm.Normal('y_pred', mu=mu, sd=epsilon, observed=y)

        trace_mlr = pm.sample(1000)
        pm.traceplot(trace_mlr)
        plt.show()

```

Pycharm、Miniconda、Win10

---

<div class="post-metadata">

**Author:** ![lucianopaz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/lucianopaz/32/2186_2.png) [@lucianopaz](https://discourse.pymc.io/u/lucianopaz)\
**Post date:** [December 5, 2018, 12:42pm UTC](https://discourse.pymc.io/t/lucianopaz-please-help-me-solve-the-windows-multiprocessing-issue/2327/5 "2018-12-05T12:42:10Z")

</div>

Could you try to see if this code works?

```python
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats
# import seaborn as sns
import pymc3 as pm
import pandas as pd

N = 100
alpha_real = 2.5
beta_real = [0.9, 1.5]
eps_real = np.random.normal(0, 0.5, size=N)

X = np.array([np.random.normal(i, j, N) for i, j in zip([10, 2], [1, 1.5])])
X_mean = X.mean(axis=1, keepdims=True)
X_centered = (X - X.mean()) # / X.std(ddof=1)
y = alpha_real + np.dot(beta_real, X) + eps_real

with pm.Model() as model_mlr:
    alpha_tmp = pm.Normal('alpha_tmp', mu=0, sd=10)
    beta = pm.Normal('beta', mu=0, sd=1, shape=2)
    epsilon = pm.HalfCauchy('epsilon', 5)

    mu = alpha_tmp + pm.math.dot(beta, X_centered)

    alpha = pm.Deterministic('alpha', alpha_tmp - pm.math.dot(beta, X_mean))

    y_pred = pm.Normal('y_pred', mu=mu, sd=epsilon, observed=y)

if __name__ == ' __main__':
    with model_mlr:
        trace_mlr = pm.sample(1000)
        pm.traceplot(trace_mlr)
        plt.show()

```

If it still does not work, does it work if you sample with 1 core like this: `trace_mlr = pm.sample(1000, cores=1)`?

---

<div class="post-metadata">

**Author:** ![lucianopaz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/lucianopaz/32/2186_2.png) [@lucianopaz](https://discourse.pymc.io/u/lucianopaz)\
**Post date:** [December 5, 2018, 12:51pm UTC](https://discourse.pymc.io/t/lucianopaz-please-help-me-solve-the-windows-multiprocessing-issue/2327/6 "2018-12-05T12:51:21Z")

</div>

Another question

Can you run a simple stand alone `theano` code without errors? Something like the following:

```python
import numpy as np
import theano
from theano import tensor as tt

x = tt.dmatrix('x')
y = tt.dmatrix('y')
z = tt.dot(x, y)
f = theano.function([x, y], z)

print(f(np.random.randn(2, 10), np.random.randn(10, 4)))

```

---

<div class="post-metadata">

**Author:** ![Abraxas2071](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/abraxas2071/32/1287_2.png) [@Abraxas2071](https://discourse.pymc.io/u/Abraxas2071)\
**Post date:** [December 5, 2018, 1:11pm UTC](https://discourse.pymc.io/t/lucianopaz-please-help-me-solve-the-windows-multiprocessing-issue/2327/7 "2018-12-05T13:11:52Z")

</div>

@lucianopaz  
Pymc3’s charioteer， Bayesian’s faithful follower，and Sickness’s fighter，Our Dear Luciano， Glory to you！

In order not to delay learning the book《Bayesian Analysis with Python》，I uninstalled miniconda, otherwise I couldn’t run the code  
So when I reinstall miniconda and input “conda install pymc3” for try your code  
Oh GOD！I’m going crazy fast~o(╥﹏╥)o  
Warning happen:

 ![A](https://canada1.discourse-cdn.com/flex036/uploads/pymc3/original/2X/4/44645de56a2b9507b044cef74b89a6bb5eee0179.jpeg)

===========================================  
I install / unstall over and over again “matplotlib”、“pymc3” by Pycharm or input “conda install / uninstall”  
But the warning still exist…  
找不到指定模块 mean is can’t find module

---

<div class="post-metadata">

**Author:** ![lucianopaz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/lucianopaz/32/2186_2.png) [@lucianopaz](https://discourse.pymc.io/u/lucianopaz)\
**Post date:** [December 5, 2018, 1:33pm UTC](https://discourse.pymc.io/t/lucianopaz-please-help-me-solve-the-windows-multiprocessing-issue/2327/8 "2018-12-05T13:33:52Z")

</div>

The installation is still wrong.

Just to better understand, @Abraxas2071, you completely removed miniconda and all of the packages installed under it, then you re installed miniconda, and finally just ran `conda install pymc3`?

Then when you are trying to run your script, are you writing `python.exe Global_Observer.py` yourself or is PyCharm doing that for you? Maybe PyCharm is using a different python installation than the one done by `conda`.

Could you open a Command Prompt and type `where python` or `where python.exe`?

---

<div class="post-metadata">

**Author:** ![lucianopaz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/lucianopaz/32/2186_2.png) [@lucianopaz](https://discourse.pymc.io/u/lucianopaz)\
**Post date:** [December 5, 2018, 1:36pm UTC](https://discourse.pymc.io/t/lucianopaz-please-help-me-solve-the-windows-multiprocessing-issue/2327/9 "2018-12-05T13:36:53Z")

</div>

Part 3 of [this link](https://medium.com/@GalarnykMichael/setting-up-pycharm-with-anaconda-plus-installing-packages-windows-mac-db2b158bd8c) describes how to select from inside PyCharm, the python executable that is installed by miniconda or anaconda. Then there is also [this one here](https://medium.com/infinity-aka-aseem/how-to-setup-pycharm-with-an-anaconda-virtual-environment-already-created-fb927bacbe61). Maybe they could help you

---

<div class="post-metadata">

**Author:** ![Abraxas2071](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/abraxas2071/32/1287_2.png) [@Abraxas2071](https://discourse.pymc.io/u/Abraxas2071)\
**Post date:** [December 5, 2018, 1:54pm UTC](https://discourse.pymc.io/t/lucianopaz-please-help-me-solve-the-windows-multiprocessing-issue/2327/10 "2018-12-05T13:54:25Z")

</div>

@lucianopaz  
Pymc3’s charioteer， Bayesian’s faithful follower，and Sickness’s fighter，Our Dear Luciano， Glory to you！

> [@lucianopaz](#):
>
> Just to better understand, @Abraxas2071, you completely removed miniconda and all of the packages installed under it, then you re installed miniconda, and finally just ran `conda install pymc3` ?

Yes！Finally just~  
I’m so sorry for my badly English~

> [@lucianopaz](#):
>
> Then when you are trying to run your script, are you writing `python.exe Global_Observer.py` yourself or is PyCharm doing that for you? Maybe PyCharm is using a different python installation than the one done by `conda` .

Myself add the .py  
However use PyCharm or miniconda’s “conda install / uninstall”, the wrong still exist

> [@lucianopaz](#):
>
> Could you open a Command Prompt and type `where python` or `where python.exe` ?

![cmd](https://canada1.discourse-cdn.com/flex036/uploads/pymc3/original/2X/2/27ee06cdc9d4a27e594c9e19b840d601e346e9a1.jpeg) ![ine](https://canada1.discourse-cdn.com/flex036/uploads/pymc3/original/2X/e/e4da13f5a94e890251c26a20742415c217d22813.jpeg)

---

<div class="post-metadata">

**Author:** ![Abraxas2071](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/abraxas2071/32/1287_2.png) [@Abraxas2071](https://discourse.pymc.io/u/Abraxas2071)\
**Post date:** [December 5, 2018, 1:55pm UTC](https://discourse.pymc.io/t/lucianopaz-please-help-me-solve-the-windows-multiprocessing-issue/2327/11 "2018-12-05T13:55:32Z")

</div>

> [@lucianopaz](#):
>
> Part 3 of [this link](https://medium.com/@GalarnykMichael/setting-up-pycharm-with-anaconda-plus-installing-packages-windows-mac-db2b158bd8c) describes how to select from inside PyCharm, the python executable that is installed by miniconda or anaconda. Then there is also [this one here](https://medium.com/infinity-aka-aseem/how-to-setup-pycharm-with-an-anaconda-virtual-environment-already-created-fb927bacbe61). Maybe they could help you

China’s Internet has some restrictions。I can’t open the links

---

<div class="post-metadata">

**Author:** ![lucianopaz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/lucianopaz/32/2186_2.png) [@lucianopaz](https://discourse.pymc.io/u/lucianopaz)\
**Post date:** [December 5, 2018, 2:03pm UTC](https://discourse.pymc.io/t/lucianopaz-please-help-me-solve-the-windows-multiprocessing-issue/2327/12 "2018-12-05T14:03:20Z")

</div>

Ok, so the problem is that you are not running the python executable that is installed by mini conda. I’ll copy paste from the links how to force pycharm to use the python installed by anaconda

---

<div class="post-metadata">

**Author:** ![junpenglao](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/junpenglao/32/8_2.png) [@junpenglao](https://discourse.pymc.io/u/junpenglao)\
**Post date:** [December 5, 2018, 2:04pm UTC](https://discourse.pymc.io/t/lucianopaz-please-help-me-solve-the-windows-multiprocessing-issue/2327/13 "2018-12-05T14:04:33Z")

</div>

Or run your program line by line in the terminal - it’s much easier to learn and debug

---

<div class="post-metadata">

**Author:** ![lucianopaz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/lucianopaz/32/2186_2.png) [@lucianopaz](https://discourse.pymc.io/u/lucianopaz)\
**Post date:** [December 5, 2018, 2:06pm UTC](https://discourse.pymc.io/t/lucianopaz-please-help-me-solve-the-windows-multiprocessing-issue/2327/14 "2018-12-05T14:06:16Z")

</div>

I’m copy pasting from one of the links, it will be formatted wrong because I’m on my phone:

I recently had to add an anaconda environment to already created conda environment and faced some issue. Thought I will explain this so others don’t have to go through the same thing.

I am using PyCharm community edition 2017.3.4 so if you are using any other version of PyCharm you will have to use your JetBrains tool skills to change the steps. [Check this video](https://medium.com/infinity-aka-aseem/master-your-tools-intelij-idea-pycharm-7dff67ce0cf9) out if you want to improve those skills. [A JetBrains employee told me](https://twitter.com/paulweveritt/status/978359231538778112) he intends to do a PyCharm version too.

Now the actual steps for this version

- Click on Configure \> Settings to open up settings in PyCharm
- Search for “Project Interpreter”. My PyCharm looks like this

 ![](https://yyz2.discourse-cdn.com/flex036/uploads/pymc3/original/2X/6/656ff47e4255ee558d112e16619f46e85445883d.png)

- Click on Add local via the settings on the right side

![](https://yyz2.discourse-cdn.com/flex036/uploads/pymc3/original/2X/1/1991fd9f1682bf9594dffadc12e7c2a285be3a36.png)

- Select “conda environment”
- Click on “Existing environment” and navigate to the environment that you want to use. Note that you have to select the bin/python file inside the conda environment for PyCharm to be able to recognise the environment
- Make sure to click the “Make available to all projects” if you want the interpreter to be used by multiple projects

 ![](https://yyz2.discourse-cdn.com/flex036/uploads/pymc3/original/2X/3/308b7bf4f98811df6dab4623cddbabda9f74d9c9.png)

- Click ok and you are done

---

<div class="post-metadata">

**Author:** ![Abraxas2071](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/abraxas2071/32/1287_2.png) [@Abraxas2071](https://discourse.pymc.io/u/Abraxas2071)\
**Post date:** [December 5, 2018, 2:23pm UTC](https://discourse.pymc.io/t/lucianopaz-please-help-me-solve-the-windows-multiprocessing-issue/2327/15 "2018-12-05T14:23:28Z")

</div>

@lucianopaz  
Pymc3’s charioteer， Bayesian’s faithful follower，and Sickness’s fighter，Our Dear Luciano， Glory to you！

The link’s method was used before open the question…But it still doesn’t work  
In a long time ago, I reinstall packages many times（like “matplotlib” “pymc3” “pandas” “numpy”）,It‘s’ working！Then warning： Windows multiprocessing issue。  
So I uninstalled it while waiting for your reply， I don’t know why it doesn’t work again

These things are frustrating。 It’s already past 10 o 'clock in China time， I will wait for your reply in my sleepＺZz…(¦3ꇤ[▓▓]

---

<div class="post-metadata">

**Author:** ![Abraxas2071](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/abraxas2071/32/1287_2.png) [@Abraxas2071](https://discourse.pymc.io/u/Abraxas2071)\
**Post date:** [December 5, 2018, 2:28pm UTC](https://discourse.pymc.io/t/lucianopaz-please-help-me-solve-the-windows-multiprocessing-issue/2327/16 "2018-12-05T14:28:42Z")

</div>

@junpenglao  
Thank you~  
Don’t worry 。I have some basis to use PyCharm（我有一些使用Pycharm的基础，也通过它学习了Python和machine learning）  
ＺZz…(¦3ꇤ[▓▓]

---

<div class="post-metadata">

**Author:** ![Abraxas2071](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/abraxas2071/32/1287_2.png) [@Abraxas2071](https://discourse.pymc.io/u/Abraxas2071)\
**Post date:** [December 6, 2018, 12:40am UTC](https://discourse.pymc.io/t/lucianopaz-please-help-me-solve-the-windows-multiprocessing-issue/2327/17 "2018-12-06T00:40:51Z")

</div>

@lucianopaz  
Pymc3’s charioteer， Bayesian’s faithful follower，and Sickness’s fighter，Our Dear Luciano， Glory to you！

I’m awake~I’m waiting for you~(oﾟ▽ﾟ)o

---

<div class="post-metadata">

**Author:** ![lucianopaz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/lucianopaz/32/2186_2.png) [@lucianopaz](https://discourse.pymc.io/u/lucianopaz)\
**Post date:** [December 6, 2018, 6:21am UTC](https://discourse.pymc.io/t/lucianopaz-please-help-me-solve-the-windows-multiprocessing-issue/2327/18 "2018-12-06T06:21:54Z")

</div>

Could you try to run this and tell me what gets printed out?

```python
import sys, numpy, theano
print(sys.path)
print(numpy. __file__ )
print(theano. __file__ )

```

---

<div class="post-metadata">

**Author:** ![Abraxas2071](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/abraxas2071/32/1287_2.png) [@Abraxas2071](https://discourse.pymc.io/u/Abraxas2071)\
**Post date:** [December 6, 2018, 6:48am UTC](https://discourse.pymc.io/t/lucianopaz-please-help-me-solve-the-windows-multiprocessing-issue/2327/19 "2018-12-06T06:48:19Z")

</div>

@lucianopaz  
Pymc3’s charioteer， Bayesian’s faithful follower，and Sickness’s fighter，Our Dear Luciano， Glory to you！

I can’t run the code…Because——

 ![1](https://canada1.discourse-cdn.com/flex036/uploads/pymc3/original/2X/b/b63b72ae70d0715b5c11caca740084eb9f66f4aa.jpeg)

==============================================  
I uninstalled all of them（Python3.7 and miniconda，All uninstall） except Pycharm and reinstalled miniconda, This warning still exists  
Now I can’t do anything except install Python3.7 separately。I can’t test any of your code  
o(╥﹏╥)oDear Luciano。。。What shall I do？？Help…Help…

---

<div class="post-metadata">

**Author:** ![lucianopaz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/lucianopaz/32/2186_2.png) [@lucianopaz](https://discourse.pymc.io/u/lucianopaz)\
**Post date:** [December 6, 2018, 7:05am UTC](https://discourse.pymc.io/t/lucianopaz-please-help-me-solve-the-windows-multiprocessing-issue/2327/20 "2018-12-06T07:05:22Z")

</div>

But your picture says that the project interpreter is the mini conda python.exe. It also says that numpy and theano are already installed.

---

<div class="post-metadata">

**Author:** ![Abraxas2071](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/abraxas2071/32/1287_2.png) [@Abraxas2071](https://discourse.pymc.io/u/Abraxas2071)\
**Post date:** [December 6, 2018, 8:35am UTC](https://discourse.pymc.io/t/lucianopaz-please-help-me-solve-the-windows-multiprocessing-issue/2327/21 "2018-12-06T08:35:26Z")

</div>

@lucianopaz  
Pymc3’s charioteer， Bayesian’s faithful follower，and Sickness’s fighter，Our Dear Luciano， Glory to you！

I have one Good News and one Bad News。I know you love Bad News first，haahaa~  
Bad News：I lost my bankcard，So I went to apply for a bank card，Sorry to have kept you waiting so long。  
Good News：I reinstalled Python3.7 and choose it as the environment for Pycharm，But did’t work。So I choose miniconda again。  
The miracle happened！It is working！We finally got down to the issue：

================== no “cores=1” =====================

 ![1](https://canada1.discourse-cdn.com/flex036/uploads/pymc3/original/2X/c/cca2241173fba391eec9138675681df6c47739cc.jpeg)

================== have “cores=1” ===================

 ![2](https://canada1.discourse-cdn.com/flex036/uploads/pymc3/original/2X/2/281c425a67283ce0b7c35c4832819dd024df4c15.jpeg)

==================

> [@lucianopaz](#):
>
> Can you run a simple stand alone `theano` code without errors? Something like the following

====================

 ![3](https://canada1.discourse-cdn.com/flex036/uploads/pymc3/original/2X/7/732f21eff0c2a6ba938029931b1aa9bee004d341.jpeg)

==================

> [@lucianopaz](#):
>
> Could you try to run this and tell me what gets printed out?
> 
> ```auto
> 
> ```

====================

 ![4](https://canada1.discourse-cdn.com/flex036/uploads/pymc3/original/2X/1/11f2f418fb2c65119ee8e22de50604f0a2b996a4.jpeg)

Our Dear Luciano。What’s your opinion？；ヾ(◍°∇°◍)ﾉﾞ

[Next page](https://discourse.pymc.io/t/lucianopaz-please-help-me-solve-the-windows-multiprocessing-issue/2327.md?page=2)
