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.

Numpy ImportError: cannot import name 'sliding_window_view' from 'numpy.lib.stride_tricks'

See original GitHub issue

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:

C:\Users\chuck\Downloads>pip3 install pandas-ta-master.zip
<snip>a bunch of installation details....</snip>
Successfully built pandas-ta
Installing collected packages: pandas-ta
Successfully installed pandas-ta-0.2.75b0

C:\Users\chuck\Downloads>

=== Below is the result of simply trying to import the library =====

>>> import pandas_ta as pta
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import pandas_ta as pta
  File "C:\Users\chuck\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas_ta\__init__.py", line 116, in <module>
    from pandas_ta.core import *
  File "C:\Users\chuck\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas_ta\core.py", line 4, in <module>
    from pandas_ta.candles.cdl_pattern import ALL_PATTERNS
  File "C:\Users\chuck\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas_ta\candles\__init__.py", line 2, in <module>
    from .cdl_doji import cdl_doji
  File "C:\Users\chuck\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas_ta\candles\cdl_doji.py", line 2, in <module>
    from pandas_ta.overlap import sma
  File "C:\Users\chuck\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas_ta\overlap\__init__.py", line 6, in <module>
    from .hilo import hilo
  File "C:\Users\chuck\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas_ta\overlap\hilo.py", line 4, in <module>
    from .ma import ma
  File "C:\Users\chuck\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas_ta\overlap\ma.py", line 8, in <module>
    from .linreg import linreg
  File "C:\Users\chuck\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas_ta\overlap\linreg.py", line 6, in <module>
    from numpy.lib.stride_tricks import sliding_window_view
ImportError: cannot import name 'sliding_window_view' from 'numpy.lib.stride_tricks' (C:\Users\chuck\AppData\Local\Programs\Python\Python39\lib\site-packages\numpy\lib\stride_tricks.py)
>>> 

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

5reactions
peturssonstefancommented, Jul 2, 2021

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 $ pip install pandas_ta

Worked for me - so might work for you too.

4reactions
ctillycommented, May 6, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What's the fastest way to produce rolling window embeddings ...
Group the column values on date then inside a list comprehension iterate over each group and apply the sliding_window_view transformation, ...
Read more >
Python Rolling Average for Road Sections - Esri Community
Create a sliding window view into the array with the given window shape. Also known as rolling or moving window, the window slides...
Read more >
[SOLVED] numpy error: cannot import name multiarray
Hi, My problem with importing numpy has been solved. In my case, the problem was that the default python in my system wasn't...
Read more >
NumPy 1.20.0 Release Notes
numpy.lib.stride_tricks.sliding_window_view constructs views on numpy arrays that offer a sliding or moving window access to the array.
Read more >
Expert | Python Numpy - Practice Probs
With np.lib.stride_tricks.as_strided() , you can create a new view of an existing array by modifying its strides without copying or modifying its data....
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