The officially official Devuan Forum!

You are not logged in.

#1 2017-11-14 20:14:11

shirase
Member
Registered: 2017-11-14
Posts: 15  

How to install the latest python?

How can I install the latest python?  My current version is Python 2.7.9 and I'd like to install python3.5 or the latest version.

Offline

#2 2017-11-14 20:42:40

golinux
Administrator
Registered: 2016-11-25
Posts: 3,137  

Re: How to install the latest python?

Have you looked in devuan backports?

Online

#3 2017-11-14 21:01:15

shirase
Member
Registered: 2017-11-14
Posts: 15  

Re: How to install the latest python?

golinux wrote:

Have you looked in devuan backports?

I'm a beginner so bare with me, am I doing this right? I added this to my /etc/apt/sources.list
# /etc/apt/sources.list.d/devuan-stable-backports.list

deb     http://auto.mirror.devuan.org/merged jessie-backports main
deb-src http://auto.mirror.devuan.org/merged jessie-backports main

ran apt-get update and apt-get install python3.6 and this is what it gave back to me.
https://pastebin.com/SrXYanqE
(I haven't typed yes or no yet I don't want to do anything that can break my system)

Offline

#4 2017-11-14 21:12:22

fsmithred
Administrator
Registered: 2016-11-25
Posts: 2,409  

Re: How to install the latest python?

NO!  Don't do it. (Not sure exactly what the package manager is trying to do there, but it looks bad.)

There's no python3.5 in jessie or jessie backports. You can get 3.4 from the regular jessie repo.

apt-get install python3

Comment out the backports lines and run 'apt-get update' again. Then install python3. If you did a full desktop install, you probably already have it.

If you want to see a list of all the python packages that are installed, run

dpkg -l | grep python

Offline

#5 2017-11-14 21:19:57

shirase
Member
Registered: 2017-11-14
Posts: 15  

Re: How to install the latest python?

fsmithred wrote:

NO!  Don't do it. (Not sure exactly what the package manager is trying to do there, but it looks bad.)

There's no python3.5 in jessie or jessie backports. You can get 3.4 from the regular jessie repo.

apt-get install python3

Comment out the backports lines and run 'apt-get update' again. Then install python3. If you did a full desktop install, you probably already have it.

If you want to see a list of all the python packages that are installed, run

dpkg -l | grep python

I did what you said and I do have python3.4 already installed. Thanks for your help.
Is there a way I can set this python version as default? When I run python --version it says Python 2.7.9

Last edited by shirase (2017-11-14 21:20:28)

Offline

#6 2017-11-14 21:33:20

ralph.ronnquist
Administrator
From: Clifton Hill, Victoria, AUS
Registered: 2016-11-30
Posts: 1,106  

Re: How to install the latest python?

By the looks of it, "python" doesn't make use of the "alternatives" set up, but have /usr/bin/python as a link (to python2.7). You might change that but that could have severe ramifications, because there are more than a few system programs using python, and these may well expect and/or utilize python2.7.

A safer way could be to patch it only for yourself (and not root), e.g., by having $HOME/bin early in your $PATH, and make $HOME/bin/python a link to /usr/bin/python3. That will be an override for the user but not for root.

Online

#7 2017-11-14 22:56:33

greenjeans
Member
Registered: 2017-04-07
Posts: 505  
Website

Re: How to install the latest python?

ralph.ronnquist wrote:

By the looks of it, "python" doesn't make use of the "alternatives" set up, but have /usr/bin/python as a link (to python2.7). You might change that but that could have severe ramifications, because there are more than a few system programs using python, and these may well expect and/or utilize python2.7.

The above part I bolded is 100% true.

Shirase: before it's over with you'll probably have 3 versions of Python. An easy way to test if something is needed is to try and uninstall it in Synaptic, if you get a huge list of stuff it wants to uninstall with it then you know for sure.


https://sourceforge.net/projects/vuu-do/
Vuu-do GNU/Linux, minimal Devuan-based openbox systems to build on, maximal versions if you prefer your linux fully-loaded.

Please donate to support Devuan and init freedom! https://devuan.org/os/donate

Offline

#8 2017-11-15 18:07:40

ilargi
Member
Registered: 2017-06-23
Posts: 11  

Re: How to install the latest python?

First time poster here.
Not sure if this is what you're looking for but I just add this alias to my regular user's .bashrc

alias python='/usr/bin/python3.4'

Any python scripts I run from a console will then use python3.4

Offline

#9 2017-11-26 14:13:26

shimo
Member
Registered: 2017-08-08
Posts: 4  

Re: How to install the latest python?

It's recommended to altinstall built-from-source Python so you will not be messing up with system Python that comes with the package manager (apt). Here are the steps to follow on the command line to build Python. I have tested building Python 3.6.3 on Devuan Jessie 1.0 without issues.

First, ensure that packages needed for source builds are installed/updated. You can install all the packages in one go but I listed them in separate install lines so it's easier to read/follow.

sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install -y wget curl make build-essential llvm
sudo apt-get install -y libssl-dev zlib1g-dev xz-utils
sudo apt-get install -y libbz2-dev libreadline-dev libsqlite3-dev
sudo apt-get install -y libncurses5-dev libncursesw5-dev tk-dev

Download the source of the Python version you need, extract it, and cd in to the directory.

wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz
tar xvf Python-3.6.3.tgz
cd Python-3.6.3

Build from source. Note that the number in "-j2" option can be increased up to the number of CPU cores you have to speed up compilation. If you're building from a slow CPU like embedded microprocessors (Raspberry Pi, etc.) use "-j1" and be prepared (have a movie/time waster handy) as compilation can take a while (some people said it can take a day). Also, you need at least 2GB of RAM to compile without issues.

./configure --enable-optimizations
make -j2
sudo make altinstall

After all this, Python 3.6.3 is now available at /usr/local/bin/python3.6 (update your shebang line if needed) or can be called from the command line as "python3.6". To install "global" packages to that specific version of Python use the matching pip:

sudo pip3.6 install package1 package2

However, Python development is best done using virtual environments for installing packages: see virtualenvwrapper.

At some point, you would want to upgrade or remove your built Python. You cannot just simply build again using the steps above to update Python having the same minor versions (for example, upgrading from 3.6.3 to 3.6.4 --- 3 is major version, 3.6 is the minor version, .3 or .4 is the point version): you need to first remove the older alt installation. Carefully run these commands to remove the files installed:

sudo rm -f /usr/local/bin/python3.6
sudo rm -f /usr/local/bin/pip3.6
sudo rm -f /usr/local/bin/pydoc3.6
sudo rm -rf /usr/local/bin/include/python3.6
sudo rm -f /usr/local/lib/libpython3.6m.a
sudo rm -rf /usr/local/lib/python3.6

# also run these to remove man entries, etc.
sudo rm -f /usr/local/share/man/python3.6.3
sudo rm -rf /usr/local/lib/pkgconfig

# CAREFUL with the command below, run an ls to check there are no other matching files
# except Python files, this is intended to remove other files left behind after the commands above
# ls /usr/local/bin/*3.6*
sudo rm -f /usr/local/bin/*3.6*

Last edited by shimo (2017-11-26 14:28:07)

Offline

Board footer