Sponsored Content
Top Forums UNIX for Beginners Questions & Answers How to set python2 as my default? Post 303035085 by Circuits on Tuesday 14th of May 2019 12:48:53 PM
Old 05-14-2019
How to set python2 as my default?

I am trying to figure out how to use update-alternatives to temporally set python2 as my default python interpreter. Currently, using the command:


Code:
sudo update-alternatives --config python

reports:


Code:
There is only one alternative in link group python (providing /usr/bin/python): /usr/bin/python3
Nothing to configure.

However, I do have python2 and python3 installed and working:


Code:
rob@linux044:~$ python
Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
rob@linux044:~$ python2
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15) 
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

Any idea how I could use update-alternatives to temporary set python2 as the default python interpreter? I was thinking:

Code:
sudo update-alternatives --install /usr/bin/python python3 /usr/bin/python2

or something similar should work but I am not sure and I dont want to attempt it and screw everything up.
 

7 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to set server's ip address, router, network mask and set if it is an internal or external ip?

Hello, I need to write a program which sets server's ip address, router, network mask. Program also should set if it is an internal or external ip. Maybe someone can help me ? Any information from u is very useful :b: I stopped at .. :( #!/bin/sh A=`hostname -i` echo "server ip address is $A"... (4 Replies)
Discussion started by: zagaruika
4 Replies

2. Shell Programming and Scripting

set Net:SSH:Expect timeout and set it again.

SSHing into a machine can take a few seconds, but after I'm in, the commands return quickly. I was wondering if the timeout setting can be changed once I'm logged into the machine. Does anyone know if this can be set on the fly? The problem here is, if I have to set timeout = 10, it'll take 10... (1 Reply)
Discussion started by: mrwatkin
1 Replies

3. UNIX and Linux Applications

[Urgent]Problem on setting up the apache2.2.6 and mod_wsgi3.2 and python2.5.4

Hi everyone, So far, I have done all the steps (including creating django.wsgi in the project). The step left is to turn on the httpd, but error put exit in this very last step. :( <user> #: ./apachetrl start httpd: Syntax error on line 450 of /usr/local/apache2/conf/httpd.conf: Cannot... (1 Reply)
Discussion started by: AlexCheung
1 Replies

4. Web Development

[Urgent]Problem on setting up the apache2.2.6 and mod_wsgi3.2 and python2.5.4

Hi everyone, So far, I have done all the steps (including creating django.wsgi in the project). The step left is to turn on the httpd, but error put exit in this very last step.:( <user> #: ./apachetrl start httpd: Syntax error on line 450 of /usr/local/apache2/conf/httpd.conf: Cannot load... (1 Reply)
Discussion started by: AlexCheung
1 Replies

5. Shell Programming and Scripting

python2.3 to python2.6

Hi All i have a script written in python2.3 but it no longer works for python2.6 is there an easier way to check what needs to be changed (1 Reply)
Discussion started by: ab52
1 Replies

6. Solaris

LC_ALL & LANG are set OK, but others couldn't set locale correctly.

Hi, I have a Solaris (SunOS 5.10) installed, by default with the en_AU.UTF-8 locale. I want to change it to en_US.UTF-8 With AU, I have no issues whatsoever, so I installed the language package and now locale -a shows "en_US.UTF-8". Problem is even with LC_ALL set in etc/default/init, the... (2 Replies)
Discussion started by: asdfg
2 Replies

7. Shell Programming and Scripting

Help needed with shell script to search and replace a set of strings among the set of files

Hi, I am looking for a shell script which serves the below purpose. Please find below the algorithm for the same and any help on this would be highly appreciated. 1)set of strings need to be replaced among set of files(directory may contain different types of files) 2)It should search for... (10 Replies)
Discussion started by: Amulya
10 Replies
DH_PYTHON(1)							     Debhelper							      DH_PYTHON(1)

NAME
dh_python - calculates Python dependencies and adds postinst and prerm Python scripts (deprecated) SYNOPSIS
dh_python [debhelperoptions] [-n] [-V version] [moduledirs...] DESCRIPTION
Note: This program is deprecated. You should use dh_pysupport or dh_pycentral instead. This program will do nothing if debian/pycompat or a Python-Version control file field exists. dh_python is a debhelper program that is responsible for generating the ${python:Depends} substitutions and adding them to substvars files. It will also add a postinst and a prerm script if required. The program will look at Python scripts and modules in your package, and will use this information to generate a dependency on python, with the current major version, or on pythonX.Y if your scripts or modules need a specific python version. The dependency will be substituted into your package's control file wherever you place the token ${python:Depends}. If some modules need to be byte-compiled at install time, appropriate postinst and prerm scripts will be generated. If already byte- compiled modules are found, they are removed. If you use this program, your package should build-depend on python. OPTIONS
module dirs If your package installs Python modules in non-standard directories, you can make dh_python check those directories by passing their names on the command line. By default, it will check /usr/lib/site-python, /usr/lib/$PACKAGE, /usr/share/$PACKAGE, /usr/lib/games/$PACKAGE, /usr/share/games/$PACKAGE and /usr/lib/python?.?/site-packages. Note: only /usr/lib/site-python, /usr/lib/python?.?/site-packages and the extra names on the command line are searched for binary (.so) modules. -V version If the .py files your package ships are meant to be used by a specific pythonX.Y version, you can use this option to specify the desired version, such as 2.3. Do not use if you ship modules in /usr/lib/site-python. -n, --noscripts Do not modify postinst/prerm scripts. CONFORMS TO
Debian policy, version 3.5.7 Python policy, version 0.3.7 SEE ALSO
debhelper(7) This program is a part of debhelper. AUTHOR
Josselin Mouette <joss@debian.org> most ideas stolen from Brendan O'Dea <bod@debian.org> 8.9.0ubuntu2.1 2012-06-12 DH_PYTHON(1)
All times are GMT -4. The time now is 06:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy