大网数据广告活动
服务器运维问答

What shebang for Anaconda Python on my directory of Server

· 52CE 我爱测

I have anaconda python distribution in ~/anaconda/bin/python but what shebang can I use to call this version of python instead of the old one that is default on the server? # /opt/python/bin/python2.7 is the one i've been trying

问题原文

原帖链接 · O.rka · CC BY-SA 3.0

I have anaconda python distribution in ~/anaconda/bin/python but what shebang can I use to call this version of python instead of the old one that is default on the server?

# /opt/python/bin/python2.7 is the one i've been trying

社区高分解答

原帖链接 · IgNite · CC BY-SA 4.0

To add to the already accepted answer (and reply to 0xc0de's comment), I think we can use:

#!/usr/bin/env python

Then we need to activate the Conda environment, or source the custom Python path that we want to use.

By doing so, #!/usr/bin/env will find the right Python version, and also will make sure that the script will run correctly inside the virtual environment.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2015-10-26)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。