Get into a conda environment and sequentially execute a package with subprocess

I want to get into a conda environment called ‘tensor’ and execute a package call slither-analysis that I had installed in that environment and can only be execute from terminal.

I tried some things but nothing worked out:

import subprocess'conda activate tensor | slither . --checklist >', capture_output=True, text=True, shell=True)

The ouptut is the following:

CompletedProcess(args=’ conda activate CISmartContracts | slither . --checklist >’, returncode=255, stdout=‘’, stderr=‘“slither” not recognized as internal or external command,\nprogram or executable batch file\n’)

How can I activate an environment and execute a command package inside that environment with subprocess or any other recommended python library?

Why is there | in the command line?
Should that be a ; for unix or a & for windows?

1 Like

Maybe try the “newer” run command:

conda run -n tensor slither ...

This is right! thanks

1 Like