[ACCEPTED]-How to set Python version by default in FreeBSD?-freebsd

Accepted answer
Score: 26

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


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

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

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

  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.

  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
Score: 8

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

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

The correct answer as of FreeBSD 12.0 is 3 as follows.

  1. Create a file in /tmp/makePatchPython3.6.patch with the following contents:
< DEFAULT_VERSIONS += python=3.6

This will add a line to the start 2 of your /etc/make.conf that will change the default python 1 in use on the system.

[/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.

More Related questions