How do I switch from python 2.6 to 2.7 by default

2024/7/7 6:44:36

How do I switch from python 2.6 to 2.7 by default

ls -l /usr/bin/python*
lrwxrwxrwx 1 root root    9 Jan 27 12:36 /usr/bin/python -> python2.6
lrwxrwxrwx 1 root root    9 Jan 27 12:36 /usr/bin/python2 -> python2.6
-rwxr-xr-x 2 root root 3664 Sep 13 00:25 /usr/bin/python26
-rwxr-xr-x 2 root root 3664 Sep 13 00:25 /usr/bin/python2.6
-rwxr-xr-x 1 root root 1418 Sep 13 00:25 /usr/bin/python2.6-config
-rwxr-xr-x 2 root root 3664 Nov 12 02:03 /usr/bin/python27
-rwxr-xr-x 2 root root 3664 Nov 12 02:03 /usr/bin/python2.7
lrwxrwxrwx 1 root root   22 Sep  1 09:52 /usr/bin/python3 -> /usr/local/bin/python3
lrwxrwxrwx 1 root root   16 Jan 27 12:36 /usr/bin/python-config -> python2.6-config
lrwxrwxrwx 1 root root   16 Jan 27 12:36 /usr/bin/python-config2 -> python2.6-config
Answer

A lot of Ubuntu packages use python. They also install modules in /usr/lib/pythonX.Y where (X.Y is your default python version).

The python packaging system only provides those modules for the default python.

If you change your default python, it would become your responsibility to provide those modules for the new version of python or else your system will break.

Therefore, unless you really know what you are doing (i.e. you are willing to port and maintain all those modules), I would strongly recommend not trying to change the default version of python.

Instead use virtualenv and virtualenvwrapper to allow you to switch versions at the user level.

https://en.xdnf.cn/q/119878.html

Related Q&A

How to make a flat list from nested lists? [duplicate]

This question already has answers here:Flatten an irregular (arbitrarily nested) list of lists(54 answers)Closed 1 year ago.Given a nested list of integers, implement an iterator to flatten it. Each el…

Python 2.7: import performance

currently, I am importing bunch of .py files scattered across the file system via: def do_import(name):import impfp, pathname, description = imp.find_module(name)with fp:return imp.load_module(name, fp…

change first line of a file using bash

I need to change a single line in a file. It is always in the first line of the file. It looks like:h\tn0 n1 n2 n3 n4 n5 n6 n7 n8 n9 hilu cjt 1 1000000there is a tab in all gaps except …

1 to 2 matching in two dataframes with different sizes in Python/R

please help me with this problem Ive been struggling all day lol, solution in either Python or R is fine! Please help Im really stuck!!! I have two dataframes - df1 has 44 rows, df2 has 100 rows, they …

Can someone fix this? pip install intents

Im not sure why this is failing but I need help to fix it please Ive been trying to fix it for about 2 hours now and cant figure it out. I have tried to restart my computer, look it up on google etc. b…

Calculating Average Performance Measures in M/M/1 System Using SimPy

I am seeking to calculate the average waiting times, and average service times in the following M/M/1 queueing system, but I am not able to calculate the averages. It writes down to the console each cu…

Python: Whats the difference between import X and from X import *? [duplicate]

This question already has answers here:Use import module or from module import?(23 answers)Closed 7 years ago.I use to think both are equal until I tried this:$python Python 2.7.13 (default, Dec 17 20…

Python iterate through pixels of image

Im trying to iterate through pixels of an image. I set the size and then use a for loop, however I get a type error: object not iterable. I have imported PIL and Imagew=100 h=200 im=im.resize((w,h), Im…

Geocoding with Geopy and big data

I have this CSV file which im feeding with this python scriptimport csv from geopy.geocoders import OpenCagegeolocator = OpenCage() #here some parameters are needed with open(/Users/Ian/Desktop/Test02/…

an error in sending json data to flask server [duplicate]

This question already has answers here:How to get POSTed JSON in Flask?(13 answers)Closed 1 year ago.I have a json data as {"age":59.0,"bp":70.0,"sg":1.01,"al":…