twopirllc / pandas-ta

Technical Analysis Indicators - Pandas TA is an easy to use Python 3 Pandas Extension with 150+ Indicators
https://twopirllc.github.io/pandas-ta/
MIT License
5.46k stars 1.06k forks source link

Import failing due to breaking change in numpy lib #804

Closed MysticMith closed 4 months ago

MysticMith commented 4 months ago
ImportError: cannot import name 'NaN' from 'numpy' (/usr/local/lib/python3.12/site-packages/numpy/__init__.py). Did you mean: 'nan'?
from numpy import NaN as npNaN
File "/usr/local/lib/python3.12/site-packages/pandas_ta/momentum/squeeze_pro.py", line 2, in <module>
from .squeeze_pro import squeeze_pro
File "/usr/local/lib/python3.12/site-packages/pandas_ta/momentum/__init__.py", line 34, in <module>
from pandas_ta.momentum import *
File "/usr/local/lib/python3.12/site-packages/pandas_ta/core.py", line 18, in <module>
from pandas_ta.core import *
File "/usr/local/lib/python3.12/site-packages/pandas_ta/__init__.py", line 116, in <module>
from pandas_ta.candles import ha

The line - "from pandas_ta.core import *" triggers an init that is breaking at "from numpy import NaN as npNaN".

Looks like numpy has changed NaN to nan.

twopirllc commented 4 months ago

Hello @MysticMith,

Some Bug Reporting Points Worth Reading

Which version are you running? The lastest version is on Github. Pip is for major releases.

import pandas_ta as ta
print(ta.version)

Do you have TA Lib also installed in your environment?

$ pip list

Have you tried the development version? Did it resolve the issue?

$ pip install -U git+https://github.com/twopirllc/pandas-ta.git@development

Describe the bug A clear and concise description of what the bug is.

To Reproduce Provide sample code.

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

Thanks for using Pandas TA!

Rydo111 commented 4 months ago

Is this issue fixed making a simple change of:

from numpy import nan as npNaN ? ...instead of NaN?

twopirllc commented 4 months ago

@Rydo111 @MysticMith

It is one way to resolve. But Pandas TA version 0.3.14b will not be supporting numpy 2.0. Use the last numpy version of 1.6.x.

Some of this discussed already in Issue #799 with PRs #800 & #801.

If you absolutely need numpy 2.x, you should be using the development branch after those have been applied.

Kind Regards, KJ

MysticMith commented 4 months ago

Hi, I am using major release from pip. running it inside container.

I understand the temporary fix but i will wait for the fix in the major release.

This is the first time i am reporting a bug on Github, so let me know what to do next.

Thanks! Mithilesh

On Fri, Jun 28, 2024 at 11:49 PM Kevin Johnson @.***> wrote:

Which version are you running? The lastest version is on Github. Pip is for major releases.

import pandas_ta as taprint(ta.version)

Do you have TA Lib also installed in your environment?

$ pip list

Have you tried the development version? Did it resolve the issue?

$ pip install -U @.***

Describe the bug A clear and concise description of what the bug is.

To Reproduce Provide sample code.

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

Thanks for using Pandas TA!

— Reply to this email directly, view it on GitHub https://github.com/twopirllc/pandas-ta/issues/804#issuecomment-2197425034, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUXQ4IFF3QPY3OUVCXBV3FLZJWSLJAVCNFSM6AAAAABKBCNRI2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJXGQZDKMBTGQ . You are receiving this because you authored the thread.Message ID: @.***>

-- Regards, Mithilesh

twopirllc commented 4 months ago

@MysticMith

I understand the temporary fix but i will wait for the fix in the major release.

You can wait, but the development version is much better in many ways than the major release you are using.

This is the first time i am reporting a bug on Github, so let me know what to do next.

I figured that out since you deleted all the bug report questions and just dumped your stack trace of the issue with no other context. Thus I provided a link to help you learn how to describe your issue so you and others can be helped more quickly.

KJ