Installing Python 3.6 on OpenSUSE Leap 42.3
# !/bin/bash

# Step 1. Install pyenv

git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bashrc
source ~/.bashrc

# Step 2. Install missing headers for all the Python modules to be built and make sure gcc is installed

sudo zypper install readline-devel sqlite3-devel libbz2-devel zlib-devel libopenssl-devel libffi-devel gcc

# Step 3. Install the desired Python version

pyenv install 3.6.3

# Step 4. Install virtualenv

sudo zypper install python3-virtualenv

# Step 5. Create a virtual environment for the installed Python and activate it

mkdir ~/pythons
cd ~/pythons
virtualenv -p ~/.pyenv/versions/3.6.3/bin/python3.6 python3.6.3
source ./python3.6.3/bin/activate
@nisargshah95

nisargshah95 commented Sep 26, 2018

Thanks for the script! The .bashrc needs to be sourced before invoking pyenv

@antivanov
Owner Author

antivanov commented Jul 9, 2019

Thanks, updated the script

@Chiango2

Chiango2 commented Mar 4, 2020

If step 3 fails, run this before step 3
sudo mount -o remount,exec /tmp

@davecampbell

davecampbell commented Jun 8, 2020

i needed gcc on a system i was working with.
not sure if 'gcc' can just be added to step 2.
i just did 'sudo zypper install gcc' and it worked fine.

@bhagym

bhagym commented Jul 9, 2020

Nicely worked on open suse 42.2, since i struggled lot to install python3.6 since open suse does not have 3.6 rpms to install quickly, Ofcourse gcc is must most of the applications to install. Also source compilazation and installation i tried: Python-3.6.11.tgz did not go well.

@antivanov
Owner Author

antivanov commented Jul 17, 2020

Yes, gcc is required in order to be able to compile Python from sources. Added gcc to step 2 to make this requirement explicit

@Ashishkanojia
@shunghsiyu

The latest Python 3.6 release is 3.6.13, so it's probably best to replace all reference of 3.6.3 with 3.6.13 to get all the latest fixes.

Post a Comment

Previous Post Next Post