I have the below files to use python APIs from perl AnimalsWrapper.py:
import os
class AnimalsWrapper():
def __init__(self):
self.name = 'dog '
def getName(self):
os.environ['HELLO'] = 'test'
return self.name + '\n'
AnimalsWrapper.pm:
package AnimalsWrapper;
use parent qw(PythonBase);
package main;
use Inline Python;
our %ENV;
1;
PythonBase.pm
package PythonBase;
use Inline Python => <<"END";
import sys
sys.path.append('<pkgpath>/python3/3.6.3a/bin/python3')
sys.path.append('<pkgpath>/python3/3.6.3a/lib/python3.6/site-packages/')
END
1;
This is the perl script I am using to call python APIs.
#!/usr/bin/perl
use strict;
use warnings;
use lib '<path to the above python code>';
use AnimalsWrapper;
our %ENV;
my $obj = AnimalsWrapper->new();
print $obj->getName();
print $ENV{HELLO}; ==> here this says its uninitalized.
In this way there is no IPC and while calling python APIs from perl its the same process, but still environment variables are not available. Any help or suggestions here are appreciated.