我正在尝试安装应用程序 node ,但在我的环境中默认情况下是 python 3,并且需要 python 2.6。我如何更改 FreeBSD 中的默认 python 版本?
# cd /usr/local/bin
# ls -l | grep python
-r-xr-xr-x 2 root wheel 1246256 Jul 12 2011 python
-r-xr-xr-x 2 root wheel 1401 Jul 12 2011 python-config
-r-xr-xr-x 2 root wheel 6060 Jul 12 2011 python-shared
-r-xr-xr-x 2 root wheel 1408 Jul 12 2011 python-shared-config
-r-xr-xr-x 1 root wheel 3720 Jul 12 2011 python-shared2.6
-r-xr-xr-x 1 root wheel 1431 Jul 12 2011 python-shared2.6-config
-r-xr-xr-x 2 root wheel 6060 Jul 12 2011 python-shared3.1
-r-xr-xr-x 2 root wheel 1408 Jul 12 2011 python-shared3.1-config
-r-xr-xr-x 1 root wheel 1182056 Jul 12 2011 python2.6
-r-xr-xr-x 1 root wheel 1424 Jul 12 2011 python2.6-config
-r-xr-xr-x 2 root wheel 1246256 Jul 12 2011 python3.1
-r-xr-xr-x 2 root wheel 1401 Jul 12 2011 python3.1-config
最佳答案
您应该删除 python 元端口 /usr/ports/lang/python
。
然后在/etc/make.conf
中设置如下变量:
PYTHON_DEFAULT_VERSION='python3.2'
(如果你想要最新版本。或者你也可以使用python3.1
。目前,默认是python2.7
。)
现在再次安装/usr/ports/lang/python
。
请注意,ports 可以请求另一个版本的 python!
更新:自 2013 年 10 月起,有一种设置默认版本的新方法;
20131003:
AFFECTS: users of lang/python* and ports
AUTHOR: mva@FreeBSD.org
The default versions of lang/python* have been changed to support the
new DEFAULT_VERSIONS variable.
PYTHON_DEFAULT_VERSION, PYTHON2_DEFAULT_VERSION and
PYTHON3_DEFAULT_VERSION are deprecated. If you have set them in your
make.conf, you should change them something like
DEFAULT_VERSIONS=python=2.7 python2=2.7 python3=3.3
关于python - 如何在 FreeBSD 中默认设置 Python 版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9349831/