How do I upgrade Python?
Tofloor
poster avatar
tadorhead
deepin
2016-07-02 12:52
Author
I want to use python 3 for my development but the system, by default, uses python 2.7. I've used the code:

  1. alias python=python3
Copy the Code


But it only works temporarily. I want to use Python 3.5.2 permanently. I would greatly appreciate the help.
Reply Favorite View the author
All Replies
omelette
deepin
2016-07-03 06:08
#1
Why not just add 'alias python=python3' to /etc/rc.local so that it's executed at startup?
Reply View the author
tadorhead
deepin
2016-07-03 07:31
#2
I never thought of that. Thank you. could you tell me exactly where to insert the code?Here's what the file looks like :
  1. #!/bin/sh -e
  2. #
  3. # rc.local
  4. #
  5. # This script is executed at the end of each multiuser runlevel.
  6. # Make sure that the script will "exit 0" on success or any other
  7. # value on error.
  8. #
  9. # In order to enable or disable this script just change the execution
  10. # bits.
  11. #
  12. # By default this script does nothing.

  13. exit 0
Copy the Code


Reply View the author
omelette
deepin
2016-07-05 07:38
#3
Oops, sorry, missed your post.  You should put it before the 'exit 0' - but having just tried it, it doesn't work!

I did a google though, and what does work is including it in the hidden ~/.bashrc file.   But if the file doesn't exist, like it didn't on this Mint/Mate setup, create a new one, adding the alias line.  Reboot, and it (should) now default to Python3 - at least it does for me!
Reply View the author
tadorhead
deepin
2016-07-07 15:40
#4
https://bbs.deepin.org/post/31220
Oops, sorry, missed your post.  You should put it before the 'exit 0' - but having just tried it, it ...

Awesome! Fortunately, this file already exist in my etc/ folder. I'm not familiar with these bash file and need assists on where to put the code properly. Here's what the file looks like:

  1. # System-wide .bashrc file for interactive bash(1) shells.

  2. # To enable the settings / commands in this file for login shells as well,
  3. # this file has to be sourced in /etc/profile.

  4. # If not running interactively, don't do anything
  5. [ -z "$PS1" ] && return

  6. # check the window size after each command and, if necessary,
  7. # update the values of LINES and COLUMNS.
  8. shopt -s checkwinsize

  9. # set variable identifying the chroot you work in (used in the prompt below)
  10. if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
  11.     debian_chroot=$(cat /etc/debian_chroot)
  12. fi

  13. # set a fancy prompt (non-color, overwrite the one in /etc/profile)
  14. PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '

  15. # Commented out, don't overwrite xterm -T "title" -n "icontitle" by default.
  16. # If this is an xterm set the title to user@host:dir
  17. #case "$TERM" in
  18. #xterm*|rxvt*)
  19. #    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
  20. #    ;;
  21. #*)
  22. #    ;;
  23. #esac

  24. # enable bash completion in interactive shells
  25. #if ! shopt -oq posix; then
  26. #  if [ -f /usr/share/bash-completion/bash_completion ]; then
  27. #    . /usr/share/bash-completion/bash_completion
  28. #  elif [ -f /etc/bash_completion ]; then
  29. #    . /etc/bash_completion
  30. #  fi
  31. #fi

  32. # if the command-not-found package is installed, use it
  33. if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then
  34.         function command_not_found_handle {
  35.                 # check because c-n-f could've been removed in the meantime
  36.                 if [ -x /usr/lib/command-not-found ]; then
  37.                    /usr/lib/command-not-found -- "$1"
  38.                    return $?
  39.                 elif [ -x /usr/share/command-not-found/command-not-found ]; then
  40.                    /usr/share/command-not-found/command-not-found -- "$1"
  41.                    return $?
  42.                 else
  43.                    printf "%s: command not found\n" "$1" >&2
  44.                    return 127
  45.                 fi
  46.         }
  47. fi
Copy the Code
  

Thank you for your patience and help
Reply View the author
josemicoronil
deepin
2016-07-25 13:49
#5
Have you tried installing python3? I had no problem at all installing Python3 and IDLE from Synaptic :-/
Reply View the author
tadorhead
deepin
2016-08-01 18:02
#6
https://bbs.deepin.org/post/31220
Have you tried installing python3? I had no problem at all installing Python3 and IDLE from Synaptic ...

I have not! I'll try it and see if that works. Thanks for the reply!
Reply View the author
linkstat
deepin
2016-08-03 19:33
#7
in Debian-based systems, you should use alternatives.
try to install the more friendly GUI program to manage debian laternatives:

aptitude install galternatives

then run galternatives (from your desktop)

and change the default value for python alternative (and any other alternative for the system)

Greetings!
Reply View the author