Given this, importing "numpy" works but "pandas" does not:
import nimpy/nimpy
let np = pyImport("numpy")
let a = np.mean([1, 2, 3])
let f = np.sin(a)
echo "numpy check"
echo f
let pd = pyImport("pandas")
let df_temp = pd.DataFrame({"A": 1, "B": 2})
echo "pandas check"
echo df_temp
Output:
numpy check
0.909297426826
/Users/<name>/Desktop/gsoc2021/url_gen.nim(13) url_gen
/Users/<name>/Desktop/gsoc2021/nimpy/nimpy.nim(1477) pyImport
/Users/<name>/Desktop/gsoc2021/nimpy/nimpy/py_utils.nim(98) raisePythonError
Error: unhandled exception: <type 'exceptions.ImportError'>: No module named pandas [Exception]
The libraries are both in the same location (/Users/<name>/.pyenv/versions/3.7.5/lib/python3.7/site-packages)
When trying to pyImport with a pathname :
let pd = pyImport("/Users/<name>/.pyenv/versions/3.7.5/lib/python3.7/site-packages/pandas")
It gives:
Error: unhandled exception: <type ‘exceptions.ImportError’>: Import by filename is not supported.
The error messages are generated by Python from what I can tell. It looks like a path problem, but it's confusing since numpy works and pandas doesn't.Try : pip install pandas.
You probably don't have pandas installed on your Python environment. Your example runs fine.
Hi, I'm getting this error and my NumPy and Pandas run fine in my python files in the same environment. Does nimpy check for installations in a specific path?
Wild guess:
The Python you use to run numpy and pandas is not the same Python nimpy uses. (System python vs user python, or something similar)