Skip to content
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

Still getting "cannot import name 'NaN' from numpy" error #857

Open
dmike23 opened this issue Nov 28, 2024 · 7 comments
Open

Still getting "cannot import name 'NaN' from numpy" error #857

dmike23 opened this issue Nov 28, 2024 · 7 comments
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@dmike23
Copy link

dmike23 commented Nov 28, 2024

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

import pandas_ta as ta
print(ta.version)

Version: 0.3.14b0

Do you have TA Lib also installed in your environment?

$ pip list

no. should i?

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

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

yes and it did not solve it.

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

Still getting "cannot import name 'NaN' from numpy" error and have tried suggested solutions with no luck.

To Reproduce
Provide sample code.

import pandas as pd
import pandas_ta as ta

file_path = r'C:\Users\micha\OneDrive\Desktop\Algo Switcher Model\combined_output.txt'  # Replace with the actual path to your combined_output.txt

data = pd.read_csv(file_path, delimiter=';', header=None)

data['ATR'] = ta.atr(data['High'], data['Low'], data['Close'], length=14)
data['ADX'] = ta.adx(data['High'], data['Low'], data['Close'], length=14)['ADX_14']
data['+DI'] = ta.adx(data['High'], data['Low'], data['Close'], length=14)['DMP_14']
data['-DI'] = ta.adx(data['High'], data['Low'], data['Close'], length=14)['DMN_14']`

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

import pandas_ta should work !

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

image

image

Additional context
Add any other context about the problem here.

Changed the squeeze pro file to "from numpy import nan" from "from numpy import NaN as npNaN"

also tried having it as "from numpy import nan as npNaN"

neither solution worked.

Running in visual studio 2022. Python 3.9 64-bit.

@dmike23 dmike23 added the bug Something isn't working label Nov 28, 2024
@twopirllc twopirllc removed their assignment Nov 30, 2024
@twopirllc twopirllc added help wanted Extra attention is needed good first issue Good for newcomers labels Nov 30, 2024
@twopirllc
Copy link
Owner

Hello @dmike23 & @ivorynoise,

0.3.14b0

However based on the squeeze_pro.py screenshot, you are running some development version yet unidentified.

TA-Lib? no. should i?

User choice.

Still getting "cannot import name 'NaN' from numpy" error and have tried suggested solutions with no luck.

What other solutions have you tried? Be specific with the Issue numbers please.

import pandas_ta should work !

Yes, absolutely. However I have been asking for help and support for years …. 🤷🏼‍♂️

Furthermore, you have also neglected to share which dependency versions you are using for the development branch. See the development requirements.txt below to ensure you have the minimum requirements.

If it is a numpy 2.x issue:

I have addressed and explained this already. 😑 Most notably in the following Issues and PRs: #799, #801, #811, #836. Please read (again) and follow any and all relevant links for extra details. Furthermore, please familiarize yourself the Guidelines.

In short, based on the my replies in those posts:

  • It's not dead nor is it a high churn library. Please use the development version. 😎
  • Pandas TA depends on TA Lib which also has Numpy 2 issues. 🤷🏼‍♂️
    • Please advise on expediting the Numpy 2 fix for TA Lib so there is no more log jam and everyone benefits.
  • Python 3.12 removed setuptools, hence it is required for installation. Furthermore, it is listed in the development requirements.txt.

Lastly, make sure you have read up on all the links posted above so you are aware of what has happened and I can avoid repeating myself. 😉

Kind Regards,
KJ

@rifatHaqueGIT
Copy link

rifatHaqueGIT commented Dec 3, 2024

I was trying to figure out how to get Pandas ta to work around the numpy situation. I downgraded my numpy version but now im getting this error
image
I tried changing all my library versions to the ones listed in requirements.txt(these are my versions):
image
My python version is 3.10.5, I downgraded from 3.12 since this library has conflicts with that version. Any ideas what I'm doing wrong to get this error? Also I did look through all the posts and didn't see this error :(

@joaoe
Copy link

joaoe commented Dec 4, 2024

Yes, absolutely. However I have been asking for help and support for years …. 🤷🏼‍♂️

You have it fixed in the development branch, which has 351 commits more than main. Will you ever make new tags and publish a new version ?

@twopirllc
Copy link
Owner

@joaoe

You have it fixed in the development branch, which has 351 commits more than main. Will you ever make new tags and publish a new version ?

Yes, absolutely. However I have been asking for help and support for years …. 🤷🏼‍♂️

But again ...

  • It's not dead nor is it a high churn library. Please use the development version. 😎

Lastly, please spend a little time reading the links I shared above and the development README.

@twopirllc
Copy link
Owner

Hello @rifatHaqueGIT,

Created a new issue #859, for this unrelated result. All communication for that problem should continue there.

Kind Regards,
KJ

@angelaponte
Copy link

angelaponte commented Dec 9, 2024

I'm seeing this as well and have pandas_ta working fine in python 3.12.3, on Windows 10, installed via Anaconda.

My issue is when I create a Linux container image (what I've been battling most of the day), using Ubuntu 22 LTS or public.ecr.aws/docker/library/python:3.12.3-slim as a base image, and install all my required packages.

It feels like garden variety python dependency hell to me. If I find a solution, I'll post the relevant parts of my Dockerfile.

It's awesome that you developed both this package and AlphaVantage . . . thank you and wow!!!

@angelaponte
Copy link

I can confirm that the package loads in python 3.12.3 in a Linux container.

My base image is:
public.ecr.aws/docker/library/python:3.12.3-slim

Key package versions are:
numpy>=1.26.0
pandas>=2.2.0

I installed the pandas_ta version from Github:
git+https://github.com/twopirllc/pandas-ta

Here's a show and tell:
$ cat pandas_ta_demo.py
import pandas_ta

print(pandas_ta.version)

$ python pandas_ta_demo.py
0.3.14b0

I think this is the modern day version of . . . it works on my computer . . . err . . . container?

ryann-green added a commit to ryann-green/stock_predictions that referenced this issue Dec 19, 2024
discussion goin fixing production branch, using dev for now while continuing GHA development.

reference: twopirllc/pandas-ta#857
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants