简体   繁体   中英

Shell script running Python code from within conda env using macOS Automator

How can I run a shell script from within a conda env using macOS Automator ? Normally I would do:

source activate my_conda_env
python script.py

But the above does not work in Automator . The error I receive is regarding missing modules (those only installed in my_conda_env ), which indicates that the script is not started from my_conda_env .

This is what you'll need

/Users/UserFolder/anaconda/envs/env-name/bin/python3 script.py

If you don't find anaconda under your UserFolder. You'll have to find it,

  • Activate your Conda environment

  • Use this which python , to find the address of your python.

  • copy that

  • paste it before the script file

    /Copied/Address/ script.py

This will use the packages from the specified conda environment.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM