Closed shtripat closed 8 years ago
that's the way the C-API works: https://docs.python.org/2/c-api/init.html#c.Py_Initialize
void Py_Initialize()
Initialize the Python interpreter. In an application embedding Python, this should be
called before using any other Python/C API functions; with the exception of
Py_SetProgramName(), Py_SetPythonHome(), PyEval_InitThreads(), PyEval_ReleaseLock(),
and PyEval_AcquireLock().
This initializes the table of loaded modules (sys.modules), and creates the fundamental
modules __builtin__, __main__ and sys. It also initializes the module search path (sys.path).
It does not set sys.argv; use PySys_SetArgvEx() for that.
This is a no-op when called for a second time (without calling Py_Finalize() first).
There is no return value; it is a fatal error if the initialization fails.
Thanks Sebastien for detailed explanation. Now how should we go around this? Should we invoke PySys_SetArgvEx() explicitly while initialize? Do we need to do any cleanup after each pyhon call or once calling PySys_SetArgvEx() while initialize is sufficient?
Regards Shubhendu On 10 Feb 2016 16:52, "Sebastien Binet" notifications@github.com wrote:
that's the way the C-API works: https://docs.python.org/2/c-api/init.html#c.Py_Initialize
void Py_Initialize()
Initialize the Python interpreter. In an application embedding Python, this should be called before using any other Python/C API functions; with the exception of Py_SetProgramName(), Py_SetPythonHome(), PyEval_InitThreads(), PyEval_ReleaseLock(), and PyEval_AcquireLock(). This initializes the table of loaded modules (sys.modules), and creates the fundamental modules builtin, main and sys. It also initializes the module search path (sys.path). It does not set sys.argv; use PySys_SetArgvEx() for that. This is a no-op when called for a second time (without calling Py_Finalize() first). There is no return value; it is a fatal error if the initialization fails.
— Reply to this email directly or view it on GitHub https://github.com/sbinet/go-python/issues/36#issuecomment-182323087.
We are facing an issue in our project while using go-python package. It seems something related to python version and compatibility with go-python package. (python version is 2.7.10)
Issue Description
To simulate the issue I have python written as below
This python if I run from python CLI works fine as shown below
Now I have go program to invoke the same function PrintSysArgv as below
Below is the snippet of gopy wrapper I am using in above go source
The out of the execution of go program fails python side as shown below
Just a wierd thought that go-python uses a trimmed version of python which is not able to take care of "sys.argv" as such.
Can you please look into the same and suggest us accordingly.
If needed / suggested I can raise the same in wiki...
Thanks and Regards, Shubhendu