Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maintain python virtual environment across raku shell commands

Tags:

raku

Is there a way to activate a python virtual env in one raku shell command, and then access the env in the next shell command? I want to do something like this in raku. Let's assume there is an executable named "execute_software" under the "some_env" env:

shell("source some_env");
shell("execute_software XXX XXX");
shell("source deactivate");

Currently, this doesn't work for me.

Thanks!

Tao

like image 836
Tao Wang Avatar asked Nov 25 '20 15:11

Tao Wang


1 Answers

I don't know how you expected the environment to stay around after the program exits.
That is not something you can do with anything as far as I'm aware.

If that is something you want, may I suggest using Inline::Python?

use Inline::Python;
my $py = Inline::Python.new();

$py.run('print("hello world")');

use string:from<Python>;
say string::capwords('foo bar'); # prints "Foo Bar"
like image 89
Brad Gilbert Avatar answered Oct 29 '22 00:10

Brad Gilbert