如何在FreeBSD中默认设置Python版本?

时间:2022-05-25 00:21:17

I'm trying to install the application node, but by default in my environment is python 3, and requires python 2.6. How can I change the default python version in FreeBSD?

我正在尝试安装应用程序节点,但是在我的环境中默认是python3,需要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

3 个解决方案

#1


3  

You could remove /usr/local/bin/python and create a symlink to Python 2.6:

您可以删除/usr/local/bin/python并创建到Python 2.6的符号链接:

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

#2


23  

You should remove the python meta-port /usr/ports/lang/python. Then set the following variable in /etc/make.conf:

您应该删除python元端口/usr/ports/lang/python。然后在/etc/make.conf中设置如下变量:

PYTHON_DEFAULT_VERSION='python3.2'

(If you want the latest version. Alternatively you can also use python3.1. Currently, the default is python2.7.)

如果你想要最新的版本。也可以使用python3.1。目前,默认值是python2.7。

Now install /usr/ports/lang/python again. Note that ports can request another version of python!

现在安装/usr/ports/lang/python再次。注意端口可以请求另一个版本的python!

Update: Since October 2013, there is a new way of setting default versions;

更新: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

#3


-1  

mv python python.old

ln -s /usr/bin/pythonX.X  /usr/bin/python

in X.X write your version

在X。X写下你的版本

#1


3  

You could remove /usr/local/bin/python and create a symlink to Python 2.6:

您可以删除/usr/local/bin/python并创建到Python 2.6的符号链接:

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

#2


23  

You should remove the python meta-port /usr/ports/lang/python. Then set the following variable in /etc/make.conf:

您应该删除python元端口/usr/ports/lang/python。然后在/etc/make.conf中设置如下变量:

PYTHON_DEFAULT_VERSION='python3.2'

(If you want the latest version. Alternatively you can also use python3.1. Currently, the default is python2.7.)

如果你想要最新的版本。也可以使用python3.1。目前,默认值是python2.7。

Now install /usr/ports/lang/python again. Note that ports can request another version of python!

现在安装/usr/ports/lang/python再次。注意端口可以请求另一个版本的python!

Update: Since October 2013, there is a new way of setting default versions;

更新: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

#3


-1  

mv python python.old

ln -s /usr/bin/pythonX.X  /usr/bin/python

in X.X write your version

在X。X写下你的版本