microsoft / vscode-jupyter

VS Code Jupyter extension
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
MIT License
1.3k stars 294 forks source link

Interactive window results in `Broken Pipe` when samping using PyMC3 / bambi #9244

Closed nickeubank closed 2 years ago

nickeubank commented 2 years ago

Applies To

What happened?

When I attempt to sample from a PyMC3 model (or use bambi to do the same), I get a very convoluted broken pipe error.

For example, running this MWE:

import pymc3 as pm
import numpy as np

with pm.Model() as model:
    mu = pm.Normal("mu", mu=0, sigma=1)
    obs = pm.Normal("obs", mu=mu, sigma=1, observed=np.random.randn(10))
    idata = pm.sample(10)

I get this printout:

<ipython-input-2-7291ca7d051e>:6: FutureWarning: In v4.0, pm.sample will return an `arviz.InferenceData` object instead of a `MultiTrace` by default. You can pass return_inferencedata=True or return_inferencedata=False to be safe and silence this warning.
  idata = pm.sample(10)
Only 10 samples in chain.
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
Multiprocess sampling (4 chains in 4 jobs)
NUTS: [mu]
/Users/Nick/github/bayesian_analysis_notes/experiments/nwe.py:7: FutureWarning: In v4.0, pm.sample will return an `arviz.InferenceData` object instead of a `MultiTrace` by default. You can pass return_inferencedata=True or return_inferencedata=False to be safe and silence this warning.
  idata = pm.sample(10)
Only 10 samples in chain.
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
Multiprocess sampling (4 chains in 4 jobs)
NUTS: [mu]
Traceback (most recent call last):
  File "/Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/forkserver.py", line 274, in main
    code = _serve_one(child_r, fds,
  File "/Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/forkserver.py", line 313, in _serve_one
    code = spawn._main(child_r, parent_sentinel)
  File "/Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/spawn.py", line 125, in _main
    prepare(preparation_data)
  File "/Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/spawn.py", line 236, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "/Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/spawn.py", line 287, in _fixup_main_from_path
    main_content = runpy.run_path(main_path,
  File "/Users/Nick/opt/miniconda3/lib/python3.9/runpy.py", line 268, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "/Users/Nick/opt/miniconda3/lib/python3.9/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/Users/Nick/opt/miniconda3/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/Nick/github/bayesian_analysis_notes/experiments/nwe.py", line 7, in <module>
    idata = pm.sample(10)
  File "/Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/sampling.py", line 559, in sample
    trace = _mp_sample(**sample_args, **parallel_args)
  File "/Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/sampling.py", line 1461, in _mp_sample
    sampler = ps.ParallelSampler(
  File "/Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py", line 431, in __init__
    self._samplers = [
  File "/Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py", line 432, in <listcomp>
    ProcessAdapter(
  File "/Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py", line 292, in __init__
    self._process.start()
  File "/Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/process.py", line 121, in start
    self._popen = self._Popen(self)
  File "/Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/context.py", line 291, in _Popen
    return Popen(process_obj)
  File "/Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/popen_forkserver.py", line 35, in __init__
    super().__init__(process_obj)
  File "/Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/popen_fork.py", line 19, in __init__
    self._launch(process_obj)
  File "/Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/popen_forkserver.py", line 42, in _launch
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "/Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/spawn.py", line 154, in get_preparation_data
    _check_not_importing_main()
  File "/Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/spawn.py", line 134, in _check_not_importing_main
    raise RuntimeError('''
RuntimeError: 
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.

followed by this stacktrace:

---------------------------------------------------------------------------
BrokenPipeError                           Traceback (most recent call last)
/Users/Nick/github/bayesian_analysis_notes/experiments/nwe.py in <module>
      [4](file:///Users/Nick/github/bayesian_analysis_notes/experiments/nwe.py?line=3)[ mu = pm.Normal("mu", mu=0, sigma=1)
      ]()[5](file:///Users/Nick/github/bayesian_analysis_notes/experiments/nwe.py?line=4)[ obs = pm.Normal("obs", mu=mu, sigma=1, observed=np.random.randn(10))
----> ]()[6](file:///Users/Nick/github/bayesian_analysis_notes/experiments/nwe.py?line=5)[ idata = pm.sample(10)

File ~/opt/miniconda3/lib/python3.9/site-packages/pymc3/sampling.py:559, in sample(draws, step, init, n_init, start, trace, chain_idx, chains, cores, tune, progressbar, model, random_seed, discard_tuned_samples, compute_convergence_checks, callback, jitter_max_retries, return_inferencedata, idata_kwargs, mp_ctx, pickle_backend, **kwargs)
    ]()[557](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/sampling.py?line=556)[ _print_step_hierarchy(step)
    ]()[558](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/sampling.py?line=557)[ try:
--> ]()[559](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/sampling.py?line=558)[     trace = _mp_sample(**sample_args, **parallel_args)
    ]()[560](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/sampling.py?line=559)[ except pickle.PickleError:
    ]()[561](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/sampling.py?line=560)[     _log.warning("Could not pickle model, sampling singlethreaded.")

File ~/opt/miniconda3/lib/python3.9/site-packages/pymc3/sampling.py:1461, in _mp_sample(draws, tune, step, chains, cores, chain, random_seed, start, progressbar, trace, model, callback, discard_tuned_samples, mp_ctx, pickle_backend, **kwargs)
   ]()[1458](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/sampling.py?line=1457)[         strace.setup(draws + tune, idx + chain)
   ]()[1459](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/sampling.py?line=1458)[     traces.append(strace)
-> ]()[1461](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/sampling.py?line=1460)[ sampler = ps.ParallelSampler(
   ]()[1462](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/sampling.py?line=1461)[     draws,
   ]()[1463](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/sampling.py?line=1462)[     tune,
   ]()[1464](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/sampling.py?line=1463)[     chains,
   ]()[1465](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/sampling.py?line=1464)[     cores,
   ]()[1466](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/sampling.py?line=1465)[     random_seed,
   ]()[1467](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/sampling.py?line=1466)[     start,
   ]()[1468](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/sampling.py?line=1467)[     step,
   ]()[1469](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/sampling.py?line=1468)[     chain,
   ]()[1470](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/sampling.py?line=1469)[     progressbar,
   ]()[1471](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/sampling.py?line=1470)[     mp_ctx=mp_ctx,
   ]()[1472](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/sampling.py?line=1471)[     pickle_backend=pickle_backend,
   ]()[1473](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/sampling.py?line=1472)[ )
   ]()[1474](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/sampling.py?line=1473)[ try:
   ]()[1475](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/sampling.py?line=1474)[     try:

File ~/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py:431, in ParallelSampler.__init__(self, draws, tune, chains, cores, seeds, start_points, step_method, start_chain_num, progressbar, mp_ctx, pickle_backend)
    ]()[428](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=427)[             raise ValueError("dill must be installed for pickle_backend='dill'.")
    ]()[429](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=428)[         step_method_pickled = dill.dumps(step_method, protocol=-1)
--> ]()[431](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=430)[ self._samplers = [
    ]()[432](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=431)[     ProcessAdapter(
    ]()[433](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=432)[         draws,
    ]()[434](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=433)[         tune,
    ]()[435](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=434)[         step_method,
    ]()[436](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=435)[         step_method_pickled,
    ]()[437](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=436)[         chain + start_chain_num,
    ]()[438](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=437)[         seed,
    ]()[439](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=438)[         start,
    ]()[440](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=439)[         mp_ctx,
    ]()[441](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=440)[         pickle_backend,
    ]()[442](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=441)[     )
    ]()[443](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=442)[     for chain, seed, start in zip(range(chains), seeds, start_points)
    ]()[444](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=443)[ ]
    ]()[446](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=445)[ self._inactive = self._samplers.copy()
    ]()[447](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=446)[ self._finished = []

File ~/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py:432, in <listcomp>(.0)
    ]()[428](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=427)[             raise ValueError("dill must be installed for pickle_backend='dill'.")
    ]()[429](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=428)[         step_method_pickled = dill.dumps(step_method, protocol=-1)
    ]()[431](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=430)[ self._samplers = [
--> ]()[432](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=431)[     ProcessAdapter(
    ]()[433](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=432)[         draws,
    ]()[434](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=433)[         tune,
    ]()[435](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=434)[         step_method,
    ]()[436](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=435)[         step_method_pickled,
    ]()[437](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=436)[         chain + start_chain_num,
    ]()[438](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=437)[         seed,
    ]()[439](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=438)[         start,
    ]()[440](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=439)[         mp_ctx,
    ]()[441](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=440)[         pickle_backend,
    ]()[442](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=441)[     )
    ]()[443](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=442)[     for chain, seed, start in zip(range(chains), seeds, start_points)
    ]()[444](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=443)[ ]
    ]()[446](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=445)[ self._inactive = self._samplers.copy()
    ]()[447](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=446)[ self._finished = []

File ~/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py:292, in ProcessAdapter.__init__(self, draws, tune, step_method, step_method_pickled, chain, seed, start, mp_ctx, pickle_backend)
    ]()[274](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=273)[     step_method_send = step_method
    ]()[276](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=275)[ self._process = mp_ctx.Process(
    ]()[277](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=276)[     daemon=True,
    ]()[278](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=277)[     name=process_name,
   (...)
    ]()[290](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=289)[     ),
    ]()[291](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=290)[ )
--> ]()[292](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=291)[ self._process.start()
    ]()[293](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=292)[ # Close the remote pipe, so that we get notified if the other
    ]()[294](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=293)[ # end is closed.
    ]()[295](file:///Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py?line=294)[ remote_conn.close()

File ~/opt/miniconda3/lib/python3.9/multiprocessing/process.py:121, in BaseProcess.start(self)
    ]()[118](file:///Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/process.py?line=117)[ assert not _current_process._config.get('daemon'), \
    ]()[119](file:///Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/process.py?line=118)[        'daemonic processes are not allowed to have children'
    ]()[120](file:///Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/process.py?line=119)[ _cleanup()
--> ]()[121](file:///Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/process.py?line=120)[ self._popen = self._Popen(self)
    ]()[122](file:///Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/process.py?line=121)[ self._sentinel = self._popen.sentinel
    ]()[123](file:///Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/process.py?line=122)[ # Avoid a refcycle if the target function holds an indirect
    ]()[124](file:///Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/process.py?line=123)[ # reference to the process object (see bpo-30775)

File ~/opt/miniconda3/lib/python3.9/multiprocessing/context.py:291, in ForkServerProcess._Popen(process_obj)
    ]()[288](file:///Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/context.py?line=287)[ @staticmethod
    ]()[289](file:///Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/context.py?line=288)[ def _Popen(process_obj):
    ]()[290](file:///Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/context.py?line=289)[     from .popen_forkserver import Popen
--> ]()[291](file:///Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/context.py?line=290)[     return Popen(process_obj)

File ~/opt/miniconda3/lib/python3.9/multiprocessing/popen_forkserver.py:35, in Popen.__init__(self, process_obj)
     ]()[33](file:///Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/popen_forkserver.py?line=32)[ def __init__(self, process_obj):
     ]()[34](file:///Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/popen_forkserver.py?line=33)[     self._fds = []
---> ]()[35](file:///Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/popen_forkserver.py?line=34)[     super().__init__(process_obj)

File ~/opt/miniconda3/lib/python3.9/multiprocessing/popen_fork.py:19, in Popen.__init__(self, process_obj)
     ]()[17](file:///Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/popen_fork.py?line=16)[ self.returncode = None
     ]()[18](file:///Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/popen_fork.py?line=17)[ self.finalizer = None
---> ]()[19](file:///Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/popen_fork.py?line=18)[ self._launch(process_obj)

File ~/opt/miniconda3/lib/python3.9/multiprocessing/popen_forkserver.py:58, in Popen._launch(self, process_obj)
     ]()[55](file:///Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/popen_forkserver.py?line=54)[ self.finalizer = util.Finalize(self, util.close_fds,
     ]()[56](file:///Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/popen_forkserver.py?line=55)[                                (_parent_w, self.sentinel))
     ]()[57](file:///Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/popen_forkserver.py?line=56)[ with open(w, 'wb', closefd=True) as f:
---> ]()[58](file:///Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/popen_forkserver.py?line=57)[     f.write(buf.getbuffer())
     ]()[59](file:///Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/popen_forkserver.py?line=58)[ self.pid = forkserver.read_signed(self.sentinel)

BrokenPipeError: [Errno 32] Broken pipe]()

VS Code Version

Version: 1.65.0 Commit: b5205cc8eb4fbaa726835538cd82372cc0222d43 Date: 2022-03-02T11:11:20.886Z Electron: 13.5.2 Chromium: 91.0.4472.164 Node.js: 14.16.0 V8: 9.1.269.39-electron.0 OS: Darwin x64 20.6.0

Jupyter Extension Version

v2022.2.1020642448

Jupyter logs

Info 09:24:25: Process Execution: > ~/opt/miniconda3/bin/python ~/.vscode/extensions/ms-toolsai.jupyter-2022.2.1020642448/pythonFiles/normalizeSelection.py
> ~/opt/miniconda3/bin/python ~/.vscode/extensions/ms-toolsai.jupyter-2022.2.1020642448/pythonFiles/normalizeSelection.py
Info 09:24:26: Adding hash for 3 = 7291ca7d051e with 7 lines
Info 09:24:26: Executing silently Code (busy) = import builtins\n_rwho_ls = %who_ls\nbuiltins.print(_VSCODE_getVariableTypes(_rwho_ls))
Warn 09:24:34: StdErr from Kernel Process /Users/Nick/github/bayesian_analysis_notes/experiments/nwe.py:7: FutureWarning: In v4.0, pm.sample will return an `arviz.InferenceData` object instead of a `MultiTrace` by default. You can pass return_inferencedata=True or return_inferencedata=False to be safe and silence this warning.
  idata = pm.sample(10)
Only 10 samples in chain.

Warn 09:24:34: StdErr from Kernel Process Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...

Warn 09:24:36: StdErr from Kernel Process Multiprocess sampling (4 chains in 4 jobs)
NUTS: [mu]

Warn 09:24:37: StdErr from Kernel Process Traceback (most recent call last):
  File "/Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/forkserver.py", line 274, in main

Warn 09:24:37: StdErr from Kernel Process     code = _serve_one(child_r, fds,
  File "/Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/forkserver.py", line 313, in _serve_one

Warn 09:24:37: StdErr from Kernel Process     code = spawn._main(child_r, parent_sentinel)
  File "/Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/spawn.py", line 125, in _main

Warn 09:24:37: StdErr from Kernel Process     prepare(preparation_data)
  File "/Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/spawn.py", line 236, in prepare

Warn 09:24:37: StdErr from Kernel Process     _fixup_main_from_path(data['init_main_from_path'])
  File "/Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/spawn.py", line 287, in _fixup_main_from_path

Warn 09:24:37: StdErr from Kernel Process     main_content = runpy.run_path(main_path,
  File "/Users/Nick/opt/miniconda3/lib/python3.9/runpy.py", line 268, in run_path

Warn 09:24:37: StdErr from Kernel Process     return _run_module_code(code, init_globals, run_name,
  File "/Users/Nick/opt/miniconda3/lib/python3.9/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/Users/Nick/opt/miniconda3/lib/python3.9/runpy.py", line 87, in _run_code

Warn 09:24:37: StdErr from Kernel Process     exec(code, run_globals)

Warn 09:24:37: StdErr from Kernel Process   File "/Users/Nick/github/bayesian_analysis_notes/experiments/nwe.py", line 7, in <module>
    idata = pm.sample(10)
  File "/Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/sampling.py", line 559, in sample

Warn 09:24:37: StdErr from Kernel Process     trace = _mp_sample(**sample_args, **parallel_args)
  File "/Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/sampling.py", line 1461, in _mp_sample

Warn 09:24:37: StdErr from Kernel Process     sampler = ps.ParallelSampler(
  File "/Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py", line 431, in __init__

Warn 09:24:37: StdErr from Kernel Process     self._samplers = [
Warn 09:24:37: StdErr from Kernel Process 
  File "/Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py", line 432, in <listcomp>
    ProcessAdapter(
Warn 09:24:37: StdErr from Kernel Process 
  File "/Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/parallel_sampling.py", line 292, in __init__

Warn 09:24:37: StdErr from Kernel Process     self._process.start()
  File "/Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/process.py", line 121, in start

Warn 09:24:37: StdErr from Kernel Process     self._popen = self._Popen(self)
Warn 09:24:37: StdErr from Kernel Process 
  File "/Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/context.py", line 291, in _Popen

Warn 09:24:37: StdErr from Kernel Process     return Popen(process_obj)
  File "/Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/popen_forkserver.py", line 35, in __init__

Warn 09:24:37: StdErr from Kernel Process     super().__init__(process_obj)
  File "/Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/popen_fork.py", line 19, in __init__

Warn 09:24:37: StdErr from Kernel Process     self._launch(process_obj)
  File "/Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/popen_forkserver.py", line 42, in _launch

Warn 09:24:37: StdErr from Kernel Process     prep_data = spawn.get_preparation_data(process_obj._name)
  File "/Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/spawn.py", line 154, in get_preparation_data

Warn 09:24:37: StdErr from Kernel Process     _check_not_importing_main()
  File "/Users/Nick/opt/miniconda3/lib/python3.9/multiprocessing/spawn.py", line 134, in _check_not_importing_main

Warn 09:24:37: StdErr from Kernel Process     raise RuntimeError('''

Warn 09:24:37: StdErr from Kernel Process RuntimeError: 
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.

Info 09:24:37: Cancel all remaining cells true || Error
Info 09:24:37: Cancel pending cells
Info 09:24:37: Cell 3 executed with state Error
Info 09:24:37: Executing silently Code (completed) = import builtins\n_rwho_ls = %who_ls\nbuiltins.print(_VSCODE_getVariableTypes(_rwho_ls))
Error 09:24:37: Failure during variable extraction:
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Input In [4], in <module>
      1 import builtins
      2 _rwho_ls = get_ipython().run_line_magic('who_ls', '')
----> 3 builtins.print(_VSCODE_getVariableTypes(_rwho_ls))

NameError: name '_VSCODE_getVariableTypes' is not defined

Coding Language and Runtime Version

Python v3.9.7

Language Extension Version (if applicable)

v2022.3.1931132634-dev

Anaconda Version (if applicable)

miniconda 4.11.0

Running Jupyter locally or remotely?

Local

DonJayamanne commented 2 years ago

@nickeubank Thanks for filing this issue. Are you running into this same issue when you run this code outside VS Code, e.g. in Jupyter Notebook or Lab?

nickeubank commented 2 years ago

I don't run into the same issue when using Jupyter notebooks in VS code so it seems unique to the interactive window. I'm not sure what the right analog would be in JupyterLab?

nickeubank commented 2 years ago

I tried the jupyter lab ipykernel console, which seemed closest analogue, and no problems:

image

DonJayamanne commented 2 years ago

Thanks for your response. Please could you run the following cell in Jupyter lab:

nickeubank commented 2 years ago

Jupyterlab ipython kernel says: '/Users/Nick/opt/miniconda3/bin/python'

VS Code interactive window says: '/Users/Nick/opt/miniconda3/bin/python'

VS Code Jupyter Console output:

Visual Studio Code (1.65.0, undefined, desktop)
Jupyter Extension Version: 2022.3.1000681942.
Python Extension Version: 2022.3.10661003.
User belongs to experiment group 'jupyterTest'
User belongs to experiment group 'jupyterEnhancedDataViewer'
Info 19:01:16: ZMQ install verified.
Info 19:01:16: Experiment status for python is {"enabled":true,"optInto":[],"optOutFrom":[]}
Info 19:01:16: Process Execution: > ~/opt/miniconda3/bin/python -m pip list
> ~/opt/miniconda3/bin/python -m pip list
Info 19:01:25: Creating controller for interactive with interpreter ~/opt/miniconda3/bin/python
Info 19:01:25: Starting interactive window with controller ID ms-toolsai.jupyter/.jvsc74a57bd03e0a5228cb9726a24d36227c69ed0d3aac98cecda769d1c9adb080711d57f90d./Users/Nick/opt/miniconda3/python./Users/Nick/opt/miniconda3/python.-m#ipykernel_launcher (Interactive)
Info 19:01:25: Setting setActiveController for vscode-interactive:Interactive-1.interactive
Info 19:01:25: Creating controller for interactive with interpreter ~/opt/miniconda3/bin/python
Info 19:01:25: TargetController found ID: .jvsc74a57bd03e0a5228cb9726a24d36227c69ed0d3aac98cecda769d1c9adb080711d57f90d./Users/Nick/opt/miniconda3/python./Users/Nick/opt/miniconda3/python.-m#ipykernel_launcher (Interactive) for document vscode-interactive:Interactive-1.interactive
Info 19:01:25: Setting controller affinity for vscode-interactive:Interactive-1.interactive .jvsc74a57bd03e0a5228cb9726a24d36227c69ed0d3aac98cecda769d1c9adb080711d57f90d./Users/Nick/opt/miniconda3/python./Users/Nick/opt/miniconda3/python.-m#ipykernel_launcher (Interactive)
Info 19:01:26: Registering dummy command feature
Info 19:01:26: Starting Notebook in kernel.ts id = .jvsc74a57bd03e0a5228cb9726a24d36227c69ed0d3aac98cecda769d1c9adb080711d57f90d./Users/Nick/opt/miniconda3/python./Users/Nick/opt/miniconda3/python.-m#ipykernel_launcher
Info 19:01:26: Creating raw notebook for vscode-interactive:Interactive-1.interactive
Info 19:01:26: Getting preferred kernel for vscode-interactive:Interactive-1.interactive
Info 19:01:26: Computing working directory vscode-interactive:Interactive-1.interactive
Info 19:01:26: Starting raw kernel base (Python 3.9.7) for interpreter ~/opt/miniconda3/bin/python
Info 19:01:26: Kernel launching with ports 9000,9001,9002,9003,9004. Start port is 9000
Info 19:01:26: Process Execution: > ~/opt/miniconda3/bin/python -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
> ~/opt/miniconda3/bin/python -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
Info 19:01:26: Adding env Variable PYTHONNOUSERSITE to ~/opt/miniconda3/bin/python
Info 19:01:26: Process Execution: > ~/opt/miniconda3/bin/python -m ipykernel_launcher --ip=127.0.0.1 --stdin=9003 --control=9001 --hb=9000 --Session.signature_scheme="hmac-sha256" --Session.key=b"df062613-ed24-48f1-88a3-622e06f789f2" --shell=9002 --transport="tcp" --iopub=9004 --f=/var/folders/tj/s8f2_ks15h315z5thvtnhz8r0000gp/T/tmp-92300Ad0AmLf3kkIM.json
> ~/opt/miniconda3/bin/python -m ipykernel_launcher --ip=127.0.0.1 --stdin=9003 --control=9001 --hb=9000 --Session.signature_scheme="hmac-sha256" --Session.key=b"df062613-ed24-48f1-88a3-622e06f789f2" --shell=9002 --transport="tcp" --iopub=9004 --f=/var/folders/tj/s8f2_ks15h315z5thvtnhz8r0000gp/T/tmp-92300Ad0AmLf3kkIM.json
Info 19:01:26: Process Execution: cwd: ~/github/unifyingdatascience_solutions
cwd: ~/github/unifyingdatascience_solutions
Info 19:01:27: ipykernel version 6.9.1 for ~/opt/miniconda3/bin/python
Info 19:01:27: ipykernel location ~/opt/miniconda3/lib/python3.9/site-packages/ipykernel/__init__.py for ~/opt/miniconda3/bin/python
Warn 19:01:28: StdErr from Kernel Process /Users/Nick/opt/miniconda3/lib/python3.9/site-packages/traitlets/traitlets.py:2202: FutureWarning: Supporting extra quotes around strings is deprecated in traitlets 5.0. You can use 'hmac-sha256' instead of '"hmac-sha256"' if you require traitlets >=5.
  warn(

Warn 19:01:28: StdErr from Kernel Process /Users/Nick/opt/miniconda3/lib/python3.9/site-packages/traitlets/traitlets.py:2157: FutureWarning: Supporting extra quotes around Bytes is deprecated in traitlets 5.0. Use 'df062613-ed24-48f1-88a3-622e06f789f2' instead of 'b"df062613-ed24-48f1-88a3-622e06f789f2"'.
  warn(

Info 19:01:28: Kernel Output: NOTE: When using the `ipython kernel` entry point, Ctrl-C will not work.

To exit, you will have to explicitly quit this process, by either sending
"quit" from a client, or using Ctrl-\ in UNIX-like environments.

To read more about this, see https://github.com/ipython/ipython/issues/2049

To connect another client to this kernel, use:
    --existing /var/folders/tj/s8f2_ks15h315z5thvtnhz8r0000gp/T/tmp-92300Ad0AmLf3kkIM.json

Info 19:01:28: Raw session started and connected
Started kernel base (Python 3.9.7)
Info 19:01:28: Finished connecting 17d7ae1d-3813-4996-86f2-576654658b72
Info 19:01:28: Executing silently Code (idle) = import types as _VSCODE_types\nimport os\nimport hashlib as _VSCODE_hashlib\nfrom IPython import get_ip
Info 19:01:28: Executing silently Code (completed) = import types as _VSCODE_types\nimport os\nimport hashlib as _VSCODE_hashlib\nfrom IPython import get_ip
Info 19:01:28: Waiting for idle on (kernel): a7e194e6-fa7e-424a-b22e-509dc421adcd -> idle
Info 19:01:28: Finished waiting for idle on (kernel): a7e194e6-fa7e-424a-b22e-509dc421adcd -> idle
Info 19:01:34: Execute Cells request 1
Info 19:01:34: Execute Cell 1 vscode-interactive:Interactive-1.interactive
Info 19:01:34: Cell 1 executed with state Success
Info 19:01:36: Got activated conda env vars ourselves for ~/opt/miniconda3/bin/python in 9283
DonJayamanne commented 2 years ago

Thanks,

import pymc3 as pm
import numpy as np
print(pm.__file__)
print(np.__file__)
import os
os.environ

# Please strip any sensitive information from the logs when sending the output of the environment variables
DonJayamanne commented 2 years ago

Basically I"m trying to figure out why you're running into these issues and I suspect the packages are different or some of the paths (or environment variables) are different when running the kernel in VS Code.

nickeubank commented 2 years ago

I hear you. Will check in morning!

DonJayamanne commented 2 years ago

@nickeubank thank you for your patience and assistance in getting this addressed. FYI - I've tried this locally at my end and this works as expected (miniconda with Python 3.9.7 in WSL).

nickeubank commented 2 years ago

Jupyter Lab:

['/Users/Nick/github/bayesian_analysis_notes/experiments', '/Users/Nick/opt/miniconda3/lib/python39.zip', '/Users/Nick/opt/miniconda3/lib/python3.9', '/Users/Nick/opt/miniconda3/lib/python3.9/lib-dynload', '', '/Users/Nick/opt/miniconda3/lib/python3.9/site-packages']
/Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/__init__.py
/Users/Nick/opt/miniconda3/lib/python3.9/site-packages/numpy/__init__.py
environ{'TERM_PROGRAM': 'Apple_Terminal',
        'SHELL': '/bin/zsh',
        'TERM': 'xterm-color',
        'TMPDIR': '/var/folders/tj/s8f2_ks15h315z5thvtnhz8r0000gp/T/',
        'TERM_PROGRAM_VERSION': '440',
        'TERM_SESSION_ID': '50BAAC23-22E2-4F80-B23E-5B65202347ED',
        'USER': 'Nick',
        'PATH': '/Users/Nick/opt/miniconda3/lib:/Users/Nick/opt/miniconda3/bin:/Users/Nick/opt/miniconda3/condabin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/Library/TeX/texbin:/usr/local/go/bin:/usr/local/share/dotnet:/opt/X11/bin:~/.dotnet/tools:/Library/Apple/usr/bin',
        'LaunchInstanceID': 'C7492ABF-F426-448B-823B-1218DBDA1C8A',
        '__CFBundleIdentifier': 'com.apple.Terminal',
        'PWD': '/Users/Nick/github/bayesian_analysis_notes/experiments',
        'XPC_FLAGS': '0x0',
        'XPC_SERVICE_NAME': '0',
        'SHLVL': '1',
        'HOME': '/Users/Nick',
        'LOGNAME': 'Nick',
        'DISPLAY': '/private/tmp/com.apple.launchd.Ay26CJBGat/org.xquartz:0',
        'OLDPWD': '/Users/Nick/github/bayesian_analysis_notes',
        'R_HOME': '/Library/Frameworks/R.framework/Resources',
        'ZSH': '/Users/Nick/.oh-my-zsh',
        'PAGER': 'cat',
        'LESS': '-R',
        'LSCOLORS': 'Gxfxcxdxbxegedabagacad',
        'CONDA_EXE': '/Users/Nick/opt/miniconda3/bin/conda',
        '_CE_M': '',
        '_CE_CONDA': '',
        'CONDA_PYTHON_EXE': '/Users/Nick/opt/miniconda3/bin/python',
        'CONDA_SHLVL': '1',
        'CONDA_PREFIX': '/Users/Nick/opt/miniconda3',
        'CONDA_DEFAULT_ENV': 'base',
        'CONDA_PROMPT_MODIFIER': '(base) ',
        'HOST': 'x86_64-apple-darwin13.4.0',
        'CONDA_TOOLCHAIN_HOST': 'x86_64-apple-darwin13.4.0',
        'CONDA_TOOLCHAIN_BUILD': 'x86_64-apple-darwin13.4.0',
        'AR': 'x86_64-apple-darwin13.4.0-ar',
        'AS': 'x86_64-apple-darwin13.4.0-as',
        'CHECKSYMS': 'x86_64-apple-darwin13.4.0-checksyms',
        'INSTALL_NAME_TOOL': 'x86_64-apple-darwin13.4.0-install_name_tool',
        'LIBTOOL': 'x86_64-apple-darwin13.4.0-libtool',
        'LIPO': 'x86_64-apple-darwin13.4.0-lipo',
        'NM': 'x86_64-apple-darwin13.4.0-nm',
        'NMEDIT': 'x86_64-apple-darwin13.4.0-nmedit',
        'OTOOL': 'x86_64-apple-darwin13.4.0-otool',
        'PAGESTUFF': 'x86_64-apple-darwin13.4.0-pagestuff',
        'RANLIB': 'x86_64-apple-darwin13.4.0-ranlib',
        'REDO_PREBINDING': 'x86_64-apple-darwin13.4.0-redo_prebinding',
        'SEG_ADDR_TABLE': 'x86_64-apple-darwin13.4.0-seg_addr_table',
        'SEG_HACK': 'x86_64-apple-darwin13.4.0-seg_hack',
        'SEGEDIT': 'x86_64-apple-darwin13.4.0-segedit',
        'SIZE': 'x86_64-apple-darwin13.4.0-size',
        'STRINGS': 'x86_64-apple-darwin13.4.0-strings',
        'STRIP': 'x86_64-apple-darwin13.4.0-strip',
        'CLANG': 'x86_64-apple-darwin13.4.0-clang',
        'LD': 'x86_64-apple-darwin13.4.0-ld',
        'CC': 'x86_64-apple-darwin13.4.0-clang',
        'OBJC': 'x86_64-apple-darwin13.4.0-clang',
        'CC_FOR_BUILD': '/Users/Nick/opt/miniconda3/bin/x86_64-apple-darwin13.4.0-clang',
        'OBJC_FOR_BUILD': '/Users/Nick/opt/miniconda3/bin/x86_64-apple-darwin13.4.0-clang',
        'CPPFLAGS': '-D_FORTIFY_SOURCE=2 -isystem /Users/Nick/opt/miniconda3/include',
        'CFLAGS': '-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -isystem /Users/Nick/opt/miniconda3/include',
        'LDFLAGS': '-Wl,-pie -Wl,-headerpad_max_install_names -Wl,-dead_strip_dylibs -Wl,-rpath,/Users/Nick/opt/miniconda3/lib -L/Users/Nick/opt/miniconda3/lib',
        'LDFLAGS_LD': '-pie -headerpad_max_install_names -dead_strip_dylibs -rpath /Users/Nick/opt/miniconda3/lib -L/Users/Nick/opt/miniconda3/lib',
        'DEBUG_CFLAGS': '-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -Og -g -Wall -Wextra -isystem /Users/Nick/opt/miniconda3/include',
        '_CONDA_PYTHON_SYSCONFIGDATA_NAME': '_sysconfigdata_x86_64_apple_darwin13_4_0',
        'CMAKE_PREFIX_PATH': ':/Users/Nick/opt/miniconda3',
        'SDKROOT': '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk',
        'CMAKE_ARGS': '-DCMAKE_AR=/Users/Nick/opt/miniconda3/bin/x86_64-apple-darwin13.4.0-ar -DCMAKE_CXX_COMPILER_AR=/Users/Nick/opt/miniconda3/bin/x86_64-apple-darwin13.4.0-ar -DCMAKE_C_COMPILER_AR=/Users/Nick/opt/miniconda3/bin/x86_64-apple-darwin13.4.0-ar -DCMAKE_RANLIB=/Users/Nick/opt/miniconda3/bin/x86_64-apple-darwin13.4.0-ranlib -DCMAKE_CXX_COMPILER_RANLIB=/Users/Nick/opt/miniconda3/bin/x86_64-apple-darwin13.4.0-ranlib -DCMAKE_C_COMPILER_RANLIB=/Users/Nick/opt/miniconda3/bin/x86_64-apple-darwin13.4.0-ranlib -DCMAKE_LINKER=/Users/Nick/opt/miniconda3/bin/x86_64-apple-darwin13.4.0-ld -DCMAKE_STRIP=/Users/Nick/opt/miniconda3/bin/x86_64-apple-darwin13.4.0-strip -DCMAKE_INSTALL_NAME_TOOL=/Users/Nick/opt/miniconda3/bin/x86_64-apple-darwin13.4.0-install_name_tool -DCMAKE_LIBTOOL=/Users/Nick/opt/miniconda3/bin/x86_64-apple-darwin13.4.0-libtool -DCMAKE_OSX_DEPLOYMENT_TARGET= -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk',
        'MESON_ARGS': '--buildtype release',
        'ac_cv_func_malloc_0_nonnull': 'yes',
        'ac_cv_func_realloc_0_nonnull': 'yes',
        'host_alias': 'x86_64-apple-darwin13.4.0',
        'build_alias': 'x86_64-apple-darwin13.4.0',
        'BUILD': 'x86_64-apple-darwin13.4.0',
        'CLANGXX': 'x86_64-apple-darwin13.4.0-clang++',
        'CXX': 'x86_64-apple-darwin13.4.0-clang++',
        'CXX_FOR_BUILD': '/Users/Nick/opt/miniconda3/bin/x86_64-apple-darwin13.4.0-clang++',
        'CXXFLAGS': '-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -std=c++14 -isystem /Users/Nick/opt/miniconda3/include',
        'DEBUG_CXXFLAGS': '-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -std=c++14 -Og -g -Wall -Wextra -isystem /Users/Nick/opt/miniconda3/include',
        'GDAL_DATA': '/Users/Nick/opt/miniconda3/share/gdal',
        'CPL_ZIP_ENCODING': 'UTF-8',
        'GSETTINGS_SCHEMA_DIR_CONDA_BACKUP': '',
        'GSETTINGS_SCHEMA_DIR': '/Users/Nick/opt/miniconda3/share/glib-2.0/schemas',
        'PROJ_LIB': '/Users/Nick/opt/miniconda3/share/proj',
        'PROJ_NETWORK': 'ON',
        'LANG': 'en_US.UTF-8',
        '_': '/Users/Nick/opt/miniconda3/bin/jupyter',
        '__CF_USER_TEXT_ENCODING': '0x1F6:0x0:0x0',
        'PYDEVD_USE_FRAME_EVAL': 'NO',
        'JPY_PARENT_PID': '71131',
        'CLICOLOR': '1',
        'GIT_PAGER': 'cat',
        'MPLBACKEND': 'module://matplotlib_inline.backend_inline'}

And VS Code:

['/Users/Nick/github/unifyingdatascience_solutions', '/Users/Nick/opt/miniconda3/lib/python39.zip', '/Users/Nick/opt/miniconda3/lib/python3.9', '/Users/Nick/opt/miniconda3/lib/python3.9/lib-dynload', '', '/Users/Nick/opt/miniconda3/lib/python3.9/site-packages', '/Users/Nick/.local/lib/python3.9/site-packages']
/Users/Nick/opt/miniconda3/lib/python3.9/site-packages/pymc3/__init__.py
/Users/Nick/opt/miniconda3/lib/python3.9/site-packages/numpy/__init__.py
environ{'ELECTRON_RUN_AS_NODE': '1',
        'USER': 'Nick',
        '__CFBundleIdentifier': 'com.microsoft.VSCode',
        'COMMAND_MODE': 'unix2003',
        'DISPLAY': '/private/tmp/com.apple.launchd.Ay26CJBGat/org.xquartz:0',
        'LOGNAME': 'Nick',
        'PATH': '/Users/Nick/opt/miniconda3/lib:/Users/Nick/opt/miniconda3/bin:/Users/Nick/opt/miniconda3/bin:/Users/Nick/opt/miniconda3/condabin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/Library/TeX/texbin:/usr/local/go/bin:/usr/local/share/dotnet:/opt/X11/bin:~/.dotnet/tools:/Library/Apple/usr/bin',
        'SHELL': '/bin/zsh',
        'HOME': '/Users/Nick',
        '__CF_USER_TEXT_ENCODING': '0x1F6:0x0:0x0',
        'TMPDIR': '/var/folders/tj/s8f2_ks15h315z5thvtnhz8r0000gp/T/',
        'XPC_SERVICE_NAME': 'application.com.microsoft.VSCode.626920674.626920680',
        'XPC_FLAGS': '0x0',
        'ORIGINAL_XDG_CURRENT_DESKTOP': 'undefined',
        'VSCODE_CWD': '/',
        'VSCODE_NLS_CONFIG': '{"locale":"en-us","availableLanguages":{},"_languagePackSupport":true}',
        'VSCODE_CODE_CACHE_PATH': '/Users/Nick/Library/Application Support/Code/CachedData/b5205cc8eb4fbaa726835538cd82372cc0222d43',
        'VSCODE_IPC_HOOK': '/Users/Nick/Library/Application Support/Code/1.65.0-main.sock',
        'VSCODE_PID': '91764',
        'SHLVL': '0',
        'PWD': '/',
        'OLDPWD': '/',
        'R_HOME': '/Library/Frameworks/R.framework/Resources',
        'ZSH': '/Users/Nick/.oh-my-zsh',
        'PAGER': 'cat',
        'LESS': '-R',
        'LSCOLORS': 'Gxfxcxdxbxegedabagacad',
        'CONDA_EXE': '/Users/Nick/opt/miniconda3/bin/conda',
        '_CE_M': '',
        '_CE_CONDA': '',
        'CONDA_PYTHON_EXE': '/Users/Nick/opt/miniconda3/bin/python',
        'CONDA_SHLVL': '1',
        'CONDA_PREFIX': '/Users/Nick/opt/miniconda3',
        'CONDA_DEFAULT_ENV': 'base',
        'CONDA_PROMPT_MODIFIER': '(base) ',
        'CONDA_BACKUP_HOST': 'nicks-mbp.lan',
        'HOST': 'x86_64-apple-darwin13.4.0',
        'CONDA_TOOLCHAIN_HOST': 'x86_64-apple-darwin13.4.0',
        'CONDA_TOOLCHAIN_BUILD': 'x86_64-apple-darwin13.4.0',
        'AR': 'x86_64-apple-darwin13.4.0-ar',
        'AS': 'x86_64-apple-darwin13.4.0-as',
        'CHECKSYMS': 'x86_64-apple-darwin13.4.0-checksyms',
        'INSTALL_NAME_TOOL': 'x86_64-apple-darwin13.4.0-install_name_tool',
        'LIBTOOL': 'x86_64-apple-darwin13.4.0-libtool',
        'LIPO': 'x86_64-apple-darwin13.4.0-lipo',
        'NM': 'x86_64-apple-darwin13.4.0-nm',
        'NMEDIT': 'x86_64-apple-darwin13.4.0-nmedit',
        'OTOOL': 'x86_64-apple-darwin13.4.0-otool',
        'PAGESTUFF': 'x86_64-apple-darwin13.4.0-pagestuff',
        'RANLIB': 'x86_64-apple-darwin13.4.0-ranlib',
        'REDO_PREBINDING': 'x86_64-apple-darwin13.4.0-redo_prebinding',
        'SEG_ADDR_TABLE': 'x86_64-apple-darwin13.4.0-seg_addr_table',
        'SEG_HACK': 'x86_64-apple-darwin13.4.0-seg_hack',
        'SEGEDIT': 'x86_64-apple-darwin13.4.0-segedit',
        'SIZE': 'x86_64-apple-darwin13.4.0-size',
        'STRINGS': 'x86_64-apple-darwin13.4.0-strings',
        'STRIP': 'x86_64-apple-darwin13.4.0-strip',
        'CLANG': 'x86_64-apple-darwin13.4.0-clang',
        'LD': 'x86_64-apple-darwin13.4.0-ld',
        'CC': 'x86_64-apple-darwin13.4.0-clang',
        'OBJC': 'x86_64-apple-darwin13.4.0-clang',
        'CC_FOR_BUILD': '/Users/Nick/opt/miniconda3/bin/x86_64-apple-darwin13.4.0-clang',
        'OBJC_FOR_BUILD': '/Users/Nick/opt/miniconda3/bin/x86_64-apple-darwin13.4.0-clang',
        'CPPFLAGS': '-D_FORTIFY_SOURCE=2 -isystem /Users/Nick/opt/miniconda3/include',
        'CFLAGS': '-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -isystem /Users/Nick/opt/miniconda3/include',
        'LDFLAGS': '-Wl,-pie -Wl,-headerpad_max_install_names -Wl,-dead_strip_dylibs -Wl,-rpath,/Users/Nick/opt/miniconda3/lib -L/Users/Nick/opt/miniconda3/lib',
        'LDFLAGS_LD': '-pie -headerpad_max_install_names -dead_strip_dylibs -rpath /Users/Nick/opt/miniconda3/lib -L/Users/Nick/opt/miniconda3/lib',
        'DEBUG_CFLAGS': '-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -Og -g -Wall -Wextra -isystem /Users/Nick/opt/miniconda3/include',
        '_CONDA_PYTHON_SYSCONFIGDATA_NAME': '_sysconfigdata_x86_64_apple_darwin13_4_0',
        'CMAKE_PREFIX_PATH': ':/Users/Nick/opt/miniconda3',
        'SDKROOT': '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk',
        'CMAKE_ARGS': '-DCMAKE_AR=/Users/Nick/opt/miniconda3/bin/x86_64-apple-darwin13.4.0-ar -DCMAKE_CXX_COMPILER_AR=/Users/Nick/opt/miniconda3/bin/x86_64-apple-darwin13.4.0-ar -DCMAKE_C_COMPILER_AR=/Users/Nick/opt/miniconda3/bin/x86_64-apple-darwin13.4.0-ar -DCMAKE_RANLIB=/Users/Nick/opt/miniconda3/bin/x86_64-apple-darwin13.4.0-ranlib -DCMAKE_CXX_COMPILER_RANLIB=/Users/Nick/opt/miniconda3/bin/x86_64-apple-darwin13.4.0-ranlib -DCMAKE_C_COMPILER_RANLIB=/Users/Nick/opt/miniconda3/bin/x86_64-apple-darwin13.4.0-ranlib -DCMAKE_LINKER=/Users/Nick/opt/miniconda3/bin/x86_64-apple-darwin13.4.0-ld -DCMAKE_STRIP=/Users/Nick/opt/miniconda3/bin/x86_64-apple-darwin13.4.0-strip -DCMAKE_INSTALL_NAME_TOOL=/Users/Nick/opt/miniconda3/bin/x86_64-apple-darwin13.4.0-install_name_tool -DCMAKE_LIBTOOL=/Users/Nick/opt/miniconda3/bin/x86_64-apple-darwin13.4.0-libtool -DCMAKE_OSX_DEPLOYMENT_TARGET= -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk',
        'MESON_ARGS': '--buildtype release',
        'ac_cv_func_malloc_0_nonnull': 'yes',
        'ac_cv_func_realloc_0_nonnull': 'yes',
        'host_alias': 'x86_64-apple-darwin13.4.0',
        'build_alias': 'x86_64-apple-darwin13.4.0',
        'BUILD': 'x86_64-apple-darwin13.4.0',
        'CLANGXX': 'x86_64-apple-darwin13.4.0-clang++',
        'CXX': 'x86_64-apple-darwin13.4.0-clang++',
        'CXX_FOR_BUILD': '/Users/Nick/opt/miniconda3/bin/x86_64-apple-darwin13.4.0-clang++',
        'CXXFLAGS': '-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -std=c++14 -isystem /Users/Nick/opt/miniconda3/include',
        'DEBUG_CXXFLAGS': '-march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -std=c++14 -Og -g -Wall -Wextra -isystem /Users/Nick/opt/miniconda3/include',
        'GDAL_DATA': '/Users/Nick/opt/miniconda3/share/gdal',
        'CPL_ZIP_ENCODING': 'UTF-8',
        'GSETTINGS_SCHEMA_DIR_CONDA_BACKUP': '',
        'GSETTINGS_SCHEMA_DIR': '/Users/Nick/opt/miniconda3/share/glib-2.0/schemas',
        'PROJ_LIB': '/Users/Nick/opt/miniconda3/share/proj',
        'PROJ_NETWORK': 'ON',
        'CPATH': '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include',
        '_': '/Users/Nick/opt/miniconda3/bin/python',
        'VSCODE_AMD_ENTRYPOINT': 'vs/workbench/api/node/extensionHostProcess',
        'VSCODE_PIPE_LOGGING': 'true',
        'VSCODE_VERBOSE_LOGGING': 'true',
        'VSCODE_LOG_NATIVE': 'false',
        'VSCODE_IPC_HOOK_EXTHOST': '/var/folders/tj/s8f2_ks15h315z5thvtnhz8r0000gp/T/vscode-ipc-9b6c04e1-2f33-430e-b10f-25ae4b40199d.sock',
        'VSCODE_HANDLES_UNCAUGHT_ERRORS': 'true',
        'VSCODE_LOG_STACK': 'false',
        'APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL': 'true',
        'PYTHONUNBUFFERED': '1',
        'PYTHONIOENCODING': 'utf-8',
        'LC_CTYPE': 'UTF-8',
        'PYTHONNOUSERSITE': 'True',
        'PYDEVD_USE_FRAME_EVAL': 'NO',
        'TERM': 'xterm-color',
        'CLICOLOR': '1',
        'GIT_PAGER': 'cat',
        'MPLBACKEND': 'module://matplotlib_inline.backend_inline',
        'IPYKERNEL_CELL_NAME': '<ipython-input-4-3f84c0f0d106>'}
DonJayamanne commented 2 years ago

@nickeubank

import pymc3 as pm import numpy as np

with pm.Model() as model: mu = pm.Normal("mu", mu=0, sigma=1) obs = pm.Normal("obs", mu=mu, sigma=1, observed=np.random.randn(10)) idata = pm.sample(10)



* Lastly, please could you create a new conda environment and try running the code against that.
    * Please send the output from the `Jupyter` output panel
    * I suspect this might work as its a different environment and not the base conda environment.

Please let me know how this goes.
DonJayamanne commented 2 years ago

Closing this issue as its been over 4 weeks, since the information was requested. We'll be happy to reopen the issue when the requested information has been provided.