Lean  $LEAN_TAG$
QuantConnect.Python.PythonInitializer Class Reference

Helper class for Python initialization More...

Static Public Member Functions

static void Initialize (bool beginAllowThreads=true)
 Initialize python. More...
 
static void Shutdown ()
 Shutdown python More...
 
static bool AddPythonPaths (IEnumerable< string > paths)
 Adds directories to the python path at runtime More...
 
static void AddAlgorithmLocationPath (string algorithmLocation)
 Adds the algorithm location to the python path. This will make sure that AddPythonPaths keeps the algorithm location path at the beginning of the pythonpath. More...
 
static void ResetAlgorithmLocationPath ()
 Resets the algorithm location path so another can be set More...
 
static bool ActivatePythonVirtualEnvironment (string pathToVirtualEnv)
 "Activate" a virtual Python environment by prepending its library storage to Pythons path. This allows the libraries in this venv to be selected prior to our base install. Requires PYTHONNET_PYDLL to be set to base install. More...
 

Detailed Description

Helper class for Python initialization

Definition at line 31 of file PythonInitializer.cs.

Member Function Documentation

◆ Initialize()

static void QuantConnect.Python.PythonInitializer.Initialize ( bool  beginAllowThreads = true)
static

Initialize python.

In some cases, we might not need to call BeginAllowThreads, like when we're running in a python or non-threaded environment. In those cases, we can set the beginAllowThreads parameter to false.

Definition at line 51 of file PythonInitializer.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Shutdown()

static void QuantConnect.Python.PythonInitializer.Shutdown ( )
static

Shutdown python

Definition at line 76 of file PythonInitializer.cs.

Here is the call graph for this function:

◆ AddPythonPaths()

static bool QuantConnect.Python.PythonInitializer.AddPythonPaths ( IEnumerable< string >  paths)
static

Adds directories to the python path at runtime

Definition at line 100 of file PythonInitializer.cs.

Here is the caller graph for this function:

◆ AddAlgorithmLocationPath()

static void QuantConnect.Python.PythonInitializer.AddAlgorithmLocationPath ( string  algorithmLocation)
static

Adds the algorithm location to the python path. This will make sure that AddPythonPaths keeps the algorithm location path at the beginning of the pythonpath.

Definition at line 159 of file PythonInitializer.cs.

Here is the call graph for this function:

◆ ResetAlgorithmLocationPath()

static void QuantConnect.Python.PythonInitializer.ResetAlgorithmLocationPath ( )
static

Resets the algorithm location path so another can be set

Definition at line 180 of file PythonInitializer.cs.

◆ ActivatePythonVirtualEnvironment()

static bool QuantConnect.Python.PythonInitializer.ActivatePythonVirtualEnvironment ( string  pathToVirtualEnv)
static

"Activate" a virtual Python environment by prepending its library storage to Pythons path. This allows the libraries in this venv to be selected prior to our base install. Requires PYTHONNET_PYDLL to be set to base install.

If a module is already loaded, Python will use its cached version first these modules must be reloaded by reload() from importlib library

Definition at line 192 of file PythonInitializer.cs.

Here is the call graph for this function:

The documentation for this class was generated from the following file: