-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Start from 0.14.0, unwanted fork
can happened when importing statsmodels
#9289
Comments
Is there anything specific to statsmodels or is this just numpy behavior that we cannot control? |
This is a numpy issue. It uses subprocess to detect certain capabilities which is causing problems for you. Are you running in some nonstandard environment (e.g., a compiled executable?) |
I'm not pretty sure, because before 0.14.0, when I run from statsmodels.compat.patsy import monkey_patch_cat_dtype Which makes numpy to
Nope, I'm just running a regular python script. |
Yes, the monkey patch is new and due to breaks in some versions of pandas. What version of statsmodels are you using? What NumPy are you using? |
I'm using statsmodels 0.14.2 and numpy 1.26.4. Sorry I think I have post these information in the description, which is outputed by |
I can't reproduce. On ubuntu: sudo apt update\nsudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.9 python3.9-dev
virtualenv sm-test --python=python3.9
source sm-test/bin/activate
python -m pip install "statsmodels==0.14.2" "numpy==1.26.4"
python -c "import statsmodels.api as sm; print('Working')" Seems to be something specific to your install. Are you running Linux, Windows or OSX? |
Can you post the full traceback with the error details? |
Oh, I'm sorry. The trackback is printed by myself. The point of my issue is that when import statsmodels, it shouldn't execute this statement: from statsmodels.tools._testing import PytestTester Because it will activate a |
checking some details.
We could make the import also lazy in |
There is an easy fix. There is some testing code in tools that loads NumPy testing assert classes. Easy to refactor away from these imports. |
Is it only the numpy.testing asserts that cause the forking? new PR looks good to me |
Yeah, I agree your point. To my point, I just don't want to trigger fork because of importing statsmodels, especially when I run it as a service, when I start some service instance, they suddendly |
Describe the bug
When importing statsmodels, a system call
fork
is called, but I don't think it's necessry.I'm using statsmodels with numpy 1.26.1 version, but I think I can verify that we have the same issue when using numpy 2.0.
Here is relative backtrace:
The issue is that when import it, it runs this:
Then in numpy, it will run something like
fork
in the end.Code Sample, a copy-pastable example if possible
If the issue has not been resolved, please file it in the issue tracker.
Expected Output
I expected it doesn't call
fork
.Output of
import statsmodels.api as sm; sm.show_versions()
INSTALLED VERSIONS
Python: 3.9.7.final.0
OS: Darwin 22.6.0 Darwin Kernel Version 22.6.0: Mon Apr 22 20:54:28 PDT 2024; root:xnu-8796.141.3.705.2~1/RELEASE_X86_64 x86_64
byteorder: little
LC_ALL: None
LANG: None
statsmodels
Installed: 0.14.2 (/local/lib/python3.9/site-packages/statsmodels)
Required Dependencies
cython: 0.29.26 (/local/lib/python3.9/site-packages/Cython)
numpy: 1.26.4 (/local/lib/python3.9/site-packages/numpy)
scipy: 1.13.1 (/local/lib/python3.9/site-packages/scipy)
pandas: 1.5.3 (/local/lib/python3.9/site-packages/pandas)
dateutil: 2.8.2 (/local/lib/python3.9/site-packages/dateutil)
patsy: 0.5.6 (/local/lib/python3.9/site-packages/patsy)
Optional Dependencies
matplotlib: 3.6.3 (/local/lib/python3.9/site-packages/matplotlib)
backend: MacOSX
cvxopt: Not installed
joblib: Not installed
Developer Tools
IPython: 8.18.1 (/local/lib/python3.9/site-packages/IPython)
jinja2: 3.0.1 (/local/lib/python3.9/site-packages/jinja2)
sphinx: Not installed
pygments: 2.14.0 (/local/lib/python3.9/site-packages/pygments)
pytest: 6.2.4 (/local/lib/python3.9/site-packages/pytest)
virtualenv: Not installed
The text was updated successfully, but these errors were encountered: