简体   繁体   English

在/ usr / bin中为python创建链接?

[英]Create a link in /usr/bin for python?

We have a large number of scripts on an old CentOS system that begin with #!/usr/local/bin/python2.7 . 在旧的CentOS系统上,我们有大量以#!/ usr / local / bin / python2.7开头的脚本。 We are setting up a new host with RH EL7 and noticed that Python 2.7.5 is installed at /usr/bin/python2.7 instead of /user/local/bin/python2.7. 我们正在使用RH EL7设置新主机,并注意到Python 2.7.5安装在/usr/bin/python2.7而不是/user/local/bin/python2.7。 This means that the old scripts won't be able to find python on the new RH system. 这意味着旧脚本无法在新RH系统上找到python。

To avoid editing all the scripts, would simply adding at link at /usr/local/bin/python2.7 pointing to /usr/bin/python2.7 work? 为了避免编辑所有脚本,是否只需在/usr/local/bin/python2.7处添加指向/usr/bin/python2.7的链接即可? Is there a downfall to this approach? 这种方法是否有缺点?

Thank you! 谢谢!

Do it 做吧

"adding at link at /usr/local/bin/python2.7 pointing to /usr/bin/python2.7" is OK. “在/usr/local/bin/python2.7的链接处添加指向/usr/bin/python2.7的链接”是可以的。

What is not ok is the other way round. 反之亦然。

You put what you want in /usr/local/bin/ , but avoid messing with /usr/bin/ , which contains important stuff (but you don't do it so that's ok, just make sure you know what you're doing). 您将想要的内容放在/usr/local/bin/ ,但避免弄乱/usr/bin/ ,其中包含重要的内容(但是您不必这样做,这样就可以了,只需确保您知道自己在做什么)。

Xcode doesn't like symlinks, other than that, to my knowledge, there is no down side. 据我所知,Xcode不喜欢符号链接,除此之外,它也没有缺点。

If you're on Mac (and use Xcode), you may want to read "Xcode, for whatever reason, will not let you use the symbolic link at /usr/local/bin/python" to fix that issue. 如果您使用的是Mac(并使用Xcode),则可能需要阅读“由于某些原因,Xcode不会允许您使用/ usr / local / bin / python中的符号链接”来解决该问题。

On almost any modern distro, python points to python3 which in turn points to python3.7 . 在几乎所有现代发行版中, python指向python3 ,而python3则指向python3.7 So no, there's no down side to symlinking like this. 所以不,像这样的符号链接没有不利的一面。

Just know what you're doing and why you're doing it. 只知道您在做什么,为什么要这样做。

在此处输入图片说明

Removed my comment and added it as an answer, since the question doesn't appear to be closing and others were posting information on the topic as answers. 删除了我的评论并将其添加为答案,因为该问题似乎没有关闭,并且其他人将有关该主题的信息发布为答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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