<\/span><\/h2>\r\n\r\n\r\n\r\nNow we’ll build and install Python 3.6.4 from source, this is the safest and recommended way that doesn’t add any repositories that might install conflicting packages on your Debian 9 server.<\/p>\r\n\r\n\r\n\r\n
Begin by installing the required build tools for Python 3.6.4:<\/p>\r\n\r\n\r\n\r\n
# sudo apt-get install -y make build-essential libssl-dev zlib1g-dev\r\n# sudo apt-get install -y libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm\r\n# sudo apt-get install -y libncurses5-dev libncursesw5-dev xz-utils tk-dev<\/pre>\r\n\r\n\r\n\r\nDownload the Python 3.6.4 source file using ‘wget’:<\/p>\r\n\r\n\r\n\r\n
# wget https:\/\/www.python.org\/ftp\/python\/3.6.4\/Python-3.6.4.tgz<\/pre>\r\n\r\n\r\n\r\nUnpack the Python 3.6.4 source file:<\/p>\r\n\r\n\r\n\r\n
# tar xvf Python-3.6.4.tgz<\/pre>\r\n\r\n\r\n\r\nEnter the Python-3.6.4 directory and run ‘.\/configure’ to prepare the build:<\/p>\r\n\r\n\r\n\r\n
# cd Python-3.6.4\r\n# .\/configure --enable-optimizations<\/pre>\r\n\r\n\r\n\r\nThen run the following command to build Python 3.6.4:<\/p>\r\n\r\n\r\n\r\n
# make -j8<\/pre>\r\n\r\n\r\n\r\nAnd then run this command to install Python 3.6.4:<\/p>\r\n\r\n\r\n\r\n
# sudo make altinstall<\/pre>\r\n\r\n\r\n\r\nNow you can open the Python 3.6.4 interpreter by executing the following command:<\/p>\r\n\r\n\r\n\r\n
# python3.6<\/pre>\r\n\r\n\r\n\r\n