-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Description
Hi, I have tried installing numpy and gave the installed numpy path but every time I run the code I am getting this error ->
ImportError: Error importing numpy: you should not try to import numpy from
its source directory; please exit the numpy source tree, and relaunch
your python interpreter from there.
This is the code I am running ->
func runPythonCode() {
// Initialize the Python interpreter
Py_Initialize()
let pythonModulesPath = "/Users/anmol.varshney/Documents/python_modules/"
// Python code as a string
let pythonCode = """
import sys
sys.path.append('\(pythonModulesPath)')
import numpy as np
array1 = np.array([1, 2, 3, 4, 5])
array2 = np.array([10, 20, 30, 40, 50])
print(array1)
print('Hello from Python!')
"""
// Execute the Python code
pythonCode.withCString { cString in
PyRun_SimpleString(cString)
}
// Finalize the Python interpreter
Py_Finalize()
}
Please help me how to import numpy or any 3rd party python packages in this?
Metadata
Metadata
Assignees
Labels
No labels