scipy.signal doesn't allow for user modules to be named `constants`
See original GitHub issueIf you have a module named constants in your project, then if you try to use that module while at the same time using scipy.signal (and it seems any module that uses scipy.optimize), you’ll get an exception. It seems to be related to https://github.com/scipy/scipy/blame/master/scipy/optimize/_highs/cython/src/constants.pyx
Reproducing code example:
#!/bin/sh
# Don't run this in a place where you have an existing file named `constants.py`
echo "MY_IMPORTANT_CONSTANT = 1" > constants.py
python3 -c "from scipy import signal; import constants; print(constants.MY_IMPORTANT_CONSTANT)"
rm constants.py
Error message:
Traceback (most recent call last):
File "<string>", line 3, in <module>
AttributeError: module 'scipy.optimize._highs.constants' has no attribute 'MY_IMPORTANT_CONSTANT'
Scipy/Numpy/Python version information:
1.6.0 1.19.4 sys.version_info(major=3, minor=9, micro=1, releaselevel='final', serial=0)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:8 (1 by maintainers)
Top Results From Across the Web
AttributeError: 'module' object (scipy) has no attribute 'misc'
AttributeError: 'module' object (scipy) has no attribute 'misc' ; I found an equivalent function pylab.imsave which works. – moadeep. Nov 27, 2012 at...
Read more >scipy.optimize.curve_fit — SciPy v1.9.3 Manual
The method 'lm' won't work when the number of observations is less than the number of variables, use 'trf' or 'dogbox' in this...
Read more >scipy.optimize.least_squares — SciPy v1.9.3 Manual
Solve a nonlinear least-squares problem with bounds on the variables. Given the residuals f(x) (an m-D real function of n real variables) and...
Read more >SciPy 1.8.0 Release Notes — SciPy v1.9.3 Manual
Before upgrading, we recommend that users check that their own code does not use deprecated SciPy functionality (to do so, run your code...
Read more >SciPy API — SciPy v1.9.3 Manual
If a module or package doesn't define __all__ , then all names that don't ... User-visible functions should have good documentation following the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

We encountered the same issue. We resolved it by renaming our constants module to something else (which was fine, we did not like the name anyway), but it is an annoying bug.
Also encountered same issue when importing the
constantsmoduleNeed to work around the issue by renaming the
constantsmodule in the project