我正在尝试安装应用程序node,但在我的环境中,默认情况下是python3,并且需要python2.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发布于 2012-02-19 14:11:51
您可以删除/usr/local/bin/python并创建一个指向Python2.6的符号链接:
rm /usr/local/bin/python
ln -s /usr/local/bin/python2.6 /usr/local/bin/python发布于 2012-02-19 14:42:02
您应该删除python /usr/ports/lang/python。然后在/etc/make.conf中设置以下变量
PYTHON_DEFAULT_VERSION='python3.2'(如果你想要最新版本的话。或者,您也可以使用python3.1。目前,默认情况是python2.7。)
现在再次安装/usr/ports/lang/python。注意,端口可以请求另一个版本的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发布于 2019-02-25 15:27:19
FreeBSD 12.0的正确答案如下所示。
/tmp/makePatchPython3.6.patch中创建具有以下内容的文件:1,2d0
< DEFAULT_VERSIONS += python=3.6
< 这将为您的/etc/make.conf的开始添加一行代码,以更改系统上使用的默认python。
[/usr/ports/lang/python]$ sudo make deinstall
[/usr/ports/lang/python]$ sudo patch /etc/make.conf /tmp/makePatchPython3.6.patch
[/usr/ports/lang/python]$ sudo make reinstall
[/usr/ports/lang/python]$ python --version
Python 3.6.8 # This will be different depending on which python version you install.https://stackoverflow.com/questions/9349831
复制相似问题