question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Model initialization fails with Python 3.8.0

See original GitHub issue

Hi, I’m not able to initialize an instance of Model() in the virtual environment I’m currently using:

Last updated: Tue Aug 03 2021

Python implementation: CPython
Python version       : 3.8.0
IPython version      : 7.26.0

matplotlib: 3.4.2
numpy     : 1.21.1
arviz     : 0.11.2
[GCC 8.4.0]
bambi     : 0.5.0
pandas    : 1.3.1

Watermark: 2.2.0

When initializing the instance, I get this error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_17456/2793899195.py in <module>
----> 1 model = Model(
      2     formula = 'measure_response_value ~ condition + (1 | wash_round)',
      3     priors = {'condition': 'wide'},
      4     data = data,
      5     dropna = True

~/mixed_models/bayesEnv/lib/python3.8/site-packages/bambi/models.py in __init__(self, formula, data, family, priors, link, categorical, dropna, auto_scale, default_priors, noncentered, taylor)
    162                         "Please rename the term(s) to prevent an unexpected behaviour."
    163                     )
--> 164             self._add_response(self._design.response, family, link, priors_)
    165         else:
    166             raise ValueError(

~/mixed_models/bayesEnv/lib/python3.8/site-packages/bambi/models.py in _add_response(self, response, family, link, priors)
    443                 )
    444 
--> 445         if response.refclass is not None and self.family.name != "bernoulli":
    446             raise ValueError("Index notation for response only available for 'bernoulli' family")
    447 

AttributeError: 'ResponseVector' object has no attribute 'refclass'

It looks weird since

  • I’m dealing with a continuous response variable
  • the error I’m getting back is not the same I see in the traceback

I tested the same analysis before in a local environment with these settings and it worked just fine:

Last updated: Tue Aug 03 2021

Python implementation: CPython
Python version       : 3.9.5
IPython version      : 7.22.0

matplotlib: 3.4.1
numpy     : 1.20.2
arviz     : 0.11.2
bambi     : 0.5.0
pandas    : 1.2.4

Watermark: 2.2.0

Is there an easy workaround for this? (Unfortunately I can’t change the Python version in the virtual environment I’m currently using).

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
tomicaprettocommented, Aug 3, 2021

Great! Thanks for reporting the issue!

1reaction
arodavcommented, Aug 3, 2021

It works now with formulae==0.1.3, thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

[tf2.0.0] Fails to build on Python 3.8 - suggested fix (change ...
ERROR : /home/daniel/tensorflow/tensorflow/python/BUILD:341:1: C++ ... 'std::nullptr_t' to 'Py_ssize_t {aka long int}' in initialization.
Read more >
What's New In Python 3.8 — Python 3.11.1 documentation
To support both 3.8 and older, try python3-config --libs --embed first and fallback to python3-config --libs (without --embed ) if the previous command...
Read more >
CPython DLL initialization routine failed from PYC cache file
While trying to use JPype on Windows Python 3.9.0, we are running into an bizarre issue with loading the internal module which is...
Read more >
Python Initialization Configuration — Python 3.11.1 ...
New in version 3.8. Python can be initialized with Py_InitializeFromConfig() and the PyConfig structure.
Read more >
Initialization, Finalization, and Threads — Python 3.11.1 ...
When the function returns, the current thread will hold the GIL and be able to call arbitrary Python code. Failure is a fatal...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found