本文介绍了Macports选择默认的Python解释器来执行脚本吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了python_select,似乎它不会更改执行脚本的默认python,例如django-admin.py runserver(前面没有python).

I used python_select, it seems like it does not change the default python for executing scripts, for instance django-admin.py runserver (without python in front).

我该如何更改?

推荐答案

/usr/bin/python,它通常在路径中比MacPort的二进制文件夹(/opt/local/bin/python)更早(优先级更高). python_select脚本仅更改/opt/local/bin/python,因此您必须确保路径上没有其他python二进制文件优先于它.

There is /usr/bin/python, which is usually earlier in the path (has a higher precedence) than MacPort's binary folder (/opt/local/bin/python). The python_select script changes only /opt/local/bin/python, so you have to make sure there is no other python binary on your path taking precedence over it.

解决方案(以root用户身份):

Solution (as root):

mv /usr/bin/python /usr/bin/python.orig
ln -s /opt/local/bin/python /usr/bin/python
port select --set python python26

请确保将第三行中的python26替换为您想要的Python版本.

Make sure you replace python26 in the third line with your intended Python version.

几天前它在MacPort 2.0.0上对我有用.如果您有较旧的MacPorts库,则应升级它或使用python_select而不是port select --set python.

It worked for me a few days ago with MacPort 2.0.0. If you have an older MacPorts library, then you should either upgrade it or use python_select instead of port select --set python.

这篇关于Macports选择默认的Python解释器来执行脚本吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 09:54
查看更多