使用如下命令运行脚本文件和代码
命令:(torch1.10) cq@ac-Super-Server:~/medical_code/RPT-main$ bash scripts/train.sh
解释:
在train.sh文件中有代码:python3 train.py with-----意思是要运行train.py程序。为了找到train.py,所以这里要在/medical_code/RPT-main目录下运行train.sh
而在train.py中第一行代码是 #!/usr/bin/env python —》调用虚拟环境,这里要在指定的虚拟环境下运行代码,比如上面命令是进入到虚拟环境torch1.10中运行的脚本。
补充:遇到的一个错误(可能服务器没配好)
ImportError: Bad git executable.
The git executable must be specified in one of the following ways:
在train.py前面加上:
import os
os.environ[“GIT_PYTHON_REFRESH”] = “quiet”