Here gone look at setting up pyenv.
Will be using for Mint 19,work same for Ubuntu 18,for other look at wiki.
Both of these distros come with Python 3.6.5 as default Python 3 so pretty good updated.
Will be using pyenv to install
Setting up pyenv
This is a one time setup.
1. Install building tools
Look at wiki for eg Mac OS X and other distros.
Open in nano as shown under,or eg vim or text editor of choice.
pyenv test and usage
As see under no error loading using
A lot to choice from,let's go back in time and install Python 2.4 and set it Global(system wide installation).
But it's installed.
Will be using for Mint 19,work same for Ubuntu 18,for other look at wiki.
Both of these distros come with Python 3.6.5 as default Python 3 so pretty good updated.
Will be using pyenv to install
Python 3.7.2
first,later look at eg Anaconda,PyPy...ect.tom@tom-VirtualBox:~$ python -V Python 2.7.15rc1 tom@tom-VirtualBox:~$ python3 -V Python 3.6.5Why pyenv?
- pyenv will install Python or other Distribution(Anaconda,PyPy,MicroPython...ect),set it as system wide installation(or run it in a shell seesion).
- No more using python3 or pip3 or
sudo
or--user
when pip install something.
- It's always
python
andpip
to version set as global,egpip install requests
to global version.
- It's safe and will not mess with your OS,can go back to default
pyenv local system
or remove all rm -rf $(pyenv root)
Setting up pyenv
This is a one time setup.
- Install tool for building Python and distributions
- Use git to download and install pyenv
- Add 4 lines last in
~/.bashrc
1. Install building tools
Look at wiki for eg Mac OS X and other distros.
sudo apt-get update sudo apt-get install python3-dev sudo apt install python3-pip sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev # Scientific package headers(Numpy, Matplotlib, SciPy, etc.) sudo apt-get install -y libpng-dev libfreetype6-dev2. This download and install pyenv
git clone https://github.com/pyenv/pyenv.git ~/.pyenv git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtuale git clone https://github.com/pyenv/pyenv-update.git $(pyenv root)/plugins/pyenv-update3. Add to ~/.bashrc
Open in nano as shown under,or eg vim or text editor of choice.
nano ~/.bashrcAdd these 4 lines last in
~/.bashrc
# Load pyenv automatically when shell start export PATH="~/.pyenv/bin:$PATH" eval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)"Save:
Ctrl-O <enter>(save) Ctrl-X(exit)Restart shell.
pyenv test and usage
As see under no error loading using
pyenv
command.tom@tom-VirtualBox:~$ pyenv version 3.7.2 (set by /home/tom/.pyenv/version) tom@tom-VirtualBox:~$ python -V Python 3.7.2Now can look at
pyenv install --list
A lot to choice from,let's go back in time and install Python 2.4 and set it Global(system wide installation).
tom@tom-VirtualBox:~$ pyenv install 2.4 Downloading Python-2.4.tgz... -> https://www.python.org/ftp/python/2.4/Python-2.4.tgz Installing Python-2.4... Installed setuptools-1.4.2 to /home/tom/.pyenv/versions/2.4 Installed pip-1.1 to /home/tom/.pyenv/versions/2.4 tom@tom-VirtualBox:~$ pyenv global 2.4 tom@tom-VirtualBox:~$ python -V Python 2.4 tom@tom-VirtualBox:~$ pip -V usage: pip COMMAND [OPTIONS] pip: error: no such option: -VAs we see back to pip version 1.1(newest today is 18.1),it did not even have
-V
to show version.But it's installed.
tom@tom-VirtualBox:~$ pip usage: pip COMMAND [OPTIONS] pip: error: You must give a command (use "pip help" to see a list of commands)Let's go back to Python 3.7.2,flexibility is the strength of pyenv.
tom@tom-VirtualBox:~$ pyenv global 3.7.2 tom@tom-VirtualBox:~$ python -V Python 3.7.2 tom@tom-VirtualBox:~$ pip -V pip 18.1 from /home/tom/.pyenv/versions/3.7.2/lib/python3.7/site-packages/pip (python 3.7)