2012-02-19 10 views
8

Sto cercando di installare l'applicazione node, ma per impostazione predefinita nel mio ambiente è python 3 e richiede python 2.6. Come posso cambiare la versione predefinita python in FreeBSD?Come impostare la versione di Python per impostazione predefinita in FreeBSD?

# 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 

risposta

3

Si potrebbe rimuovere /usr/local/bin/python e creare un link simbolico a Python 2.6:

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

Questo deve essere ripetuto dopo ogni aggiornamento del python predefinito! La destinazione post installazione nel makefile della porta collega i binari specifici della versione ai binari senza versione. –

-1
mv python python.old 

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

in x.x scrivere la tua versione

21

È necessario rimuovere il pitone meta-port /usr/ports/lang/python. quindi impostare le seguenti variabili in /etc/make.conf:

PYTHON_DEFAULT_VERSION='python3.2' 

(... Se si desidera che l'ultima versione alternativa è possibile utilizzare anche python3.1 Attualmente, il valore predefinito è python2.7)

Ora installare /usr/ports/lang/python di nuovo. Si noti che le porte possono richiedere un'altra versione di python!

Aggiornamento: Da ottobre 2013, c'è un nuovo modo di impostare le versioni di default;

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

Grazie per aver aggiornato la tua risposta !!!! Sapevo che questo era cambiato e stavo per cercare la risposta di nuovo quando ho visto la parte aggiornata della tua risposta. –