-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Numpy ImportError: cannot import name 'sliding_window_view' from 'numpy.lib.stride_tricks' #285
Comments
Hello @ctilly, This is unfortunate bug. However it is a Numpy ImportError and not a Pandas TA bug as noted by the last statement during the import: ImportError: cannot import name 'sliding_window_view' from 'numpy.lib.stride_tricks' According to Numpy, sliding_window_view documentation says that it is New in version 1.20.0. I would ensure that you are running the correct or latest version of Numpy. If updating Numpy continues to produce this For further information about this Issue, you can dig deeper into this search if need. Please let me know when you resolve the Kind Regards, |
Yep, that was the issue, which I thought was a red herring. But in fact it is new in 1.20 and I was running 1.19. Thanks for that. |
No worries. Thanks for replying and letting me know. I appreciate it. Thanks, |
My numpy version is '1.18.4' ~/anaconda3/lib/python3.7/site-packages/pandas_ta/overlap/linreg.py in <module>
4 from numpy import nan as npNaN
5 from numpy import pi as npPi
----> 6 from numpy.lib.stride_tricks import sliding_window_view
7 from pandas import Series
8 from pandas_ta.utils import get_offset, verify_series pip uninstall pandas_ta
Found existing installation: pandas-ta 0.2.93b0
Uninstalling pandas-ta-0.2.93b0:
pip install pandas_ta
Collecting pandas_ta
Using cached pandas_ta-0.2.45b0-py3-none-any.whl My version is 'Pandas TA v0.2.45b0' and working perfectly! |
Hello @dikien, This is unfortunate bug. However it is a Numpy ImportError and not a Pandas TA bug as noted by the last statement during the import: ImportError: cannot import name 'sliding_window_view' from 'numpy.lib.stride_tricks' According to Numpy, sliding_window_view documentation says that it is New in version 1.20.0. I would ensure that you are running the correct or latest version of Numpy. If updating Numpy continues to produce this For further information about this Issue, you can dig deeper into this search if need. Please let me know when you resolve the Kind Regards, |
Ran into the same issue. Resolved it by updating numpy (current is 1.21.x): $ pip install numpy --upgrade Then reinstall pandas_ta: $ pip uninstall pandas_ta Worked for me - so might work for you too. |
Same issue!!! |
This is not a great solution since other libraries require slightly older versions of numpy. |
I am aware of this. I am open to contributions that will incorporate both versions. 😎 Thanks, |
I found two potential solutions. The first uses linreg_ = [linear_regression(_) for _ in close.rolling(length) if len(_) == length] (Replaces the following line) pandas-ta/pandas_ta/overlap/linreg.py Line 57 in 3b40553
This is very slow for some reason however, and I found a solution which is many times faster (~1.7s vs ~0.15s). It uses another similar def rolling_window(arr, window):
shape = arr.shape[:-1] + (arr.shape[-1] - window + 1, window)
strides = arr.strides + (arr.strides[-1],)
return as_strided(arr, shape=shape, strides=strides)
[...]
linreg_ = [linear_regression(_) for _ in rolling_window(npArray(close), length)] I found this solution at https://stackoverflow.com/a/6811241. |
Hello @abmyii, This sounds great! Thanks for helping to investigate an efficient and backwards compatible solution! I will give it a try as soon as I can. I appreciate it. Thanks, |
Same problem here ! |
Noted. Working on it. Kind Regards, |
Same issue here, just to report, this makes impossible to have tensorflow and pandas-ta on the same project.
|
Again:
Kind Regards, |
Hello @abmyii, @AlexandreBourrieau, @brandonculver, @dikien, @opsxcq, @peturssonstefan, @rushiai, I have an updated version on the development branch that should address the numpy version problem. I would appreciate your feedback on this when you get a chance before I update the main branch. $ pip install -U git+https://github.com/twopirllc/pandas-ta.git@development Thanks, |
@twopirllc Works well for me too - thanks! |
Hello @AlexandreBourrieau, @brandonculver, @dikien, @opsxcq, @peturssonstefan, @rushiai, New stable version v0.3.14b should help resolve this Issue. Please let me know otherwise. $ pip install pandas_ta Thanks, |
Which version are you running? The lastest version is on Github. Pip is for major releases.
version v0.2.75
Running Windows 10
Describe the bug
I just installed the version 0.2.75 from github by downloading the .zip file, then installed using pip3 install pandas-ta-master.zip
Received a notification that I didn't have 'wheels' installed so it used legacy method of install, but installation was successful.
But when I tried to add the library I get the error shown below.
I uninstalled pandas-ta, then I installed wheels. I then reinstalled pandas-ta successfully:
=== Below is the result of simply trying to import the library =====
The text was updated successfully, but these errors were encountered: