mmomtchev / pymport

Use Python libraries from Node.js
ISC License
110 stars 8 forks source link

issue with pandas_ta #305

Closed jseifeddine closed 6 days ago

jseifeddine commented 1 week ago
const ta = proxify(pymport('pandas_ta'));
                          ^
Error: Python exception: cannot import name 'NaN' from 'numpy' (/home/user/backend/node_modules/pymport/lib/binding/linux-x64/lib/python3.12/site-packages/numpy/__init__.py)
    at Object.<anonymous> (/home/user/backend/data-import.ts:5:27)
    at Module._compile (node:internal/modules/cjs/loader:1469:14)
    at Module.m._compile (/usr/lib/node_modules/ts-node/src/index.ts:1618:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
    at Object.require.extensions.<computed> [as .ts] (/usr/lib/node_modules/ts-node/src/index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1104:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:173:12)
    at phase4 (/usr/lib/node_modules/ts-node/src/bin.ts:649:14)
    at bootstrap (/usr/lib/node_modules/ts-node/src/bin.ts:95:10) {
  pythonType: PyObject {},
  pythonValue: PyObject {},
  pythonTrace: PyObject {}
}
import { RestClientV5 } from 'bybit-api'
import { pymport, proxify } from 'pymport';
const np = proxify(pymport('numpy'));
const pd = proxify(pymport('pandas'));
const ta = proxify(pymport('pandas_ta'));

const client = new RestClientV5();

client.getKline({category: "linear", symbol: "BTCUSDT", interval: "15"})
    .then(result => {
        console.log(result)
    })
    .catch(err => {
        console.error(err)
    })
mmomtchev commented 6 days ago

This is a Python exception that has nothing to do with pymport:

mmom$ node_modules/pymport/lib/binding/linux-x64/python
Python 3.12.2 (main, Apr  2 2024, 14:15:39) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import pandas
>>> import pandas_ta
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/encrypted/mmom/src/tmp/node_modules/pymport/lib/binding/linux-x64/lib/python3.12/site-packages/pandas_ta/__init__.py", line 116, in <module>
    from pandas_ta.core import *
  File "/encrypted/mmom/src/tmp/node_modules/pymport/lib/binding/linux-x64/lib/python3.12/site-packages/pandas_ta/core.py", line 18, in <module>
    from pandas_ta.momentum import *
  File "/encrypted/mmom/src/tmp/node_modules/pymport/lib/binding/linux-x64/lib/python3.12/site-packages/pandas_ta/momentum/__init__.py", line 34, in <module>
    from .squeeze_pro import squeeze_pro
  File "/encrypted/mmom/src/tmp/node_modules/pymport/lib/binding/linux-x64/lib/python3.12/site-packages/pandas_ta/momentum/squeeze_pro.py", line 2, in <module>
    from numpy import NaN as npNaN
ImportError: cannot import name 'NaN' from 'numpy' (/encrypted/mmom/src/tmp/node_modules/pymport/lib/binding/linux-x64/lib/python3.12/site-packages/numpy/__init__.py). Did you mean: 'nan'?
jseifeddine commented 6 days ago

You're right, apologies.

its fixed now thanks