2012-02-19 61 views
8

我试图安装应用程序node,但默认情况下我的环境是python 3,并且需要python 2.6。如何更改python版本FreeBSD如何在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 

回答

3

你可以删除/usr/local/bin/python,并创建一个符号链接到Python 2.6:

rm /usr/local/bin/python 
ln -s /usr/local/bin/python2.6 /usr/local/bin/python 
+2

这已经到默认的Python的每次更新后重做!端口makefile中的安装后目标将版本特定的二进制文件硬链接到无版本的二进制文件。 – 2012-02-20 22:23:33

-1
mv python python.old 

ln -s /usr/bin/pythonX.X /usr/bin/python 
在x.x中

写你的版本

21

您应该删除蟒蛇元端口/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: [email protected] 

    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 
+0

谢谢你更新你的答案!我知道这已经发生了变化,并且当我看到您的答案的更新日期部分时,我将再次回答Google的答案。 – 2017-10-29 13:30:52

相关问题