https://www.python.org/ftp/python/
cd /home
curl -O https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz
tar
tar -xzvf Python-3.7.2.tgz
Python-3-7-2
cd Python-3.7.2
./configure
mkdir -p $HOME/usr/local
make altinstall prefix=$HOME/usr/local exec-prefix=$HOME/usr/local
wait for install 5 minutes or so. Python 3 will be installed in $HOME/usr/local/bin
.
ls $HOME/usr/local/bin
2to3-3.7 easy_install-3.7 idle3.7 pip3.7 pydoc3.7 python3 python3.7 python3.7m python3.7m-config pyvenv-3.7
/home/jsyu/usr/local/bin/python3.7
Then, Python 3 shell starts.
Python 3.7.2 (default, Jan 28 2019, 13:06:35)
[GCC 6.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>
To exit, just type
exit()
Change directory to /where/you/install/python3/bin
directory again.
cd $HOME/usr/local/bin
Create your own Python 3 virtual environment file
ln -s pyvenv-3.7 pyvenv
Edit pyvenv-3.7
using vi
(or other text editor)
vi pyvenv-3.7
At the first line of file, edit the absolute path of your python. So the correct path should be like this
#!/home/rangsiman/usr/local/bin/python3.7
To make life easier, we do not always want to call Python 3 via its full path. So we can add it to PATH environment variable.
cd $HOME/usr/local/bin
ln -s python3.7 python3
$PATH
. echo "# Python 3.7.2" >> ~/.bashrc
echo "export PATH=\$HOME/usr/local/bin:\$PATH" >> ~/.bashrc
source ~/.bashrc
python3
Rangsiman Ketkaew