Skip to content

How to install numpy as an additional packages? #19

Description

@Anmol-SoC

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions