Note that I got stuck when installing Python locally. It is assumed that you do not have administrator privileges (when sudo cannot be used). I installed Python3.6.1, but I think it can be applied to other versions.
Download and extract to \ $ HOME / src, and proceed with the discussion assuming that it will be installed in \ $ HOME / local.
First, since tkinter is required for matplotlib, install tck / tk in advance. If you already have it installed and you know the installed lib and include directories, you can skip it. In my case, I didn't know the installation directory (and the version was old), so I installed it locally.
The latest version of tcl / tk is 8.6.6, so install it. Download from the link in Official Site.
First, install tcl.
cd $HOME/src
wget https://sourceforge.net/projects/tcl/files/tcl8.6.6-src.tar.gz/download -O tcl8.6.6.tar.gz
tar xzvf tcl8.6.6.tar.gz
cd tcl8.6.6
mkdir build; cd build
../unix/configure --prefix=$HOME/local/
make
make install
Install tk in the same way.
cd $HOME/src
wget https://sourceforge.net/projects/tcl/files/tk8.6.6-src.tar.gz/download -O tk8.6.6.tar.gz
tar xzvf tk8.6.6.tar.gz
cd tk8.6.6
mkdir build; cd build
../unix/configure --prefix=$HOME/local/
make
make install
Next, install Python. Note that tkinter will not work if you install it without thinking about it.
The latest version of Python is 3.6.1, so install this. Download from the link in Official Site.
cd $HOME/src
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz
tar xfv Python-3.6.1.tar.xz
cd Python-3.6.1
mkdir build; cd build
../configure --prefix=$HOME/local/ --with-tcltk-includes="-I/$HOME/local/include" \
--with-tcltk-libs="-L/$HOME/local/lib -ltcl8.6 -ltk8.6"
make
make install
It should be noted that the include directory and lib directory are optionally specified when executing configure. Without it, it throws an error when running after Python is installed. As an error message
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named '_tkinter'
You can get something like this.
Towards the end of the installation message
Python build finished successfully!
The necessary bits to build these optional modules were not found:
_gdbm _lzma
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
If you need these packages, you need to specify another option. If you are in trouble, you can refer to the setup.py script in the extracted Python directory.
If you install pip at the end, the installation is completed.
wget https://bootstrap.pypa.io/get-pip.py
$HOME/local/bin/python3 get-pip.py
You can try plt.show () etc. to check if it works.
Recommended Posts