[英]Different shebang line for a python script depending on the system
I've a python script using the Django framework running from a virtualenv, and I'd like to use the same script on a different machine where the virtualenv is located in a different place.我有一个 python 脚本,它使用从 virtualenv 运行的 Django 框架,我想在 virtualenv 位于不同位置的不同机器上使用相同的脚本。
The script is like this:脚本是这样的:
#!/home/lenovo/.virtualenvs/gjt/bin/python
sys.path.append('/home/lenovo/prj/gjt/gjt')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'gjt.settings')
import django
django.setup()
To use the same script on a different machine, I'd need to change the shebangline to something else.要在不同的机器上使用相同的脚本,我需要将 shebangline 更改为其他内容。
Thanks.谢谢。
This shebang should be suitable for different vitual environments:这个shebang应该适合不同的虚拟环境:
#!/usr/bin/env python
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.