[英]How can I activate a Python virtual environment and launch a python script, in a bash script on Mac?
I am trying to create a bash script that will simply 我正在尝试创建一个bash脚本,它将简单地
that can be double clicked and executed on Mac. 可以双击并在Mac上执行。
My script is as follows: 我的脚本如下:
#!/usr/bin/env bash
./macVenv/bin/activate
python main.py
I can run from command line just fine. 我可以从命令行运行就好了。 When I double click though it complains it cannot find the python file.
当我双击但它抱怨找不到python文件时。
Yes. 是。 The following script works on my machine.
以下脚本可在我的计算机上使用。
source activate $1
python $2
I run it by typing ./script_name py36 python_file_name 我通过输入./script_name py36 python_file_name来运行它
where script_name is the name of the script with these 2 lines. 其中script_name是这两行的脚本名称。 py36 is the name of the virtual environment and python_file_name is the python script you want to run.
py36是虚拟环境的名称,而python_file_name是要运行的python脚本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.