Over have looked at using default Python 3 installation that linux Distros has.
Now look Simple Python Version Management: pyenv
Using a new versions of Python is simple with
It's fully automated for both install and virtual environment
Everything runs as your user,so you don't have to worry about messing up the Python used by linux Distros itself.
Look at a run:
Setting up pyenv:
Install headers needed to build CPython:
Optional scientific package headers(Numpy, Matplotlib, SciPy, etc.)
Run the installer script (installs pyenv and some very useful pyenv plugins).
Add these 3 lines last in
Setting up environment:
Looked at example run first with
and making it global
Here a sample of
Setting up virtual environment with
Now look Simple Python Version Management: pyenv
Using a new versions of Python is simple with
pyenv
.pyenv install 3.6.1
to install newest version.It's fully automated for both install and virtual environment
pyenv virtualenv 3.6.1 env_36
Everything runs as your user,so you don't have to worry about messing up the Python used by linux Distros itself.
Look at a run:
Output:mint@mint ~ $ pyenv install 3.6.1
Downloading Python-3.6.1.tar.xz...
-> https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz
Installing Python-3.6.1...
Installed Python-3.6.1 to /home/mint/.pyenv/versions/3.6.1
# Make it default version
mint@mint ~ $ pyenv global 3.6.1
mint@mint ~ $ python
Python 3.6.1 (default, May 25 2017, 14:44:39)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
Setting up pyenv:
Install headers needed to build CPython:
sudo apt-get install -y build-essential libbz2-dev libssl-dev libreadline-dev libsqlite3-dev tk-dev
Optional scientific package headers(Numpy, Matplotlib, SciPy, etc.)
sudo apt-get install -y libpng-dev libfreetype6-dev
Run the installer script (installs pyenv and some very useful pyenv plugins).
git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv
Add these 3 lines last in
~/.bashrc
Output:export PATH="~/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
Example how to add lines:mint@mint ~ $ nano ~/.bashrc # paste in lines last # Ctrl-O <enter>(save) Ctrl-XRestart shell.
Setting up environment:
Looked at example run first with
pyenv install 3.6.1
,and making it global
pyenv global 3.6.1
Here a sample of
--list
available versions:Output:mint@mint ~ $ pyenv install --list
Available versions:
3.6.1
3.7-dev
anaconda3-4.3.1
miniconda3-4.3.11
ironpython-2.7.7
jython-2.7.1b3
pypy3.5-5.7.1-beta-src
pypy3.5-5.7.1-beta
pypy3-portable-5.7.0
So as a example want to test out miniconda pyenv install miniconda3-4.3.11
Setting up virtual environment with
pyenv
Output:mint@mint ~ $ pyenv virtualenv 3.6.1 env_36
# Activate environment
mint@mint ~ $ pyenv activate env_36
(env_36) mint@mint ~ $ pip -V
pip 9.0.1 from /home/mint/.pyenv/versions/3.6.1/envs/env_36/lib/python3.6/site-packages (python 3.6)
Install into environment:Output:(env_36) mint@mint ~ $ pip install requests
Collecting requests
Installing collected packages: requests
Successfully installed requests-2.14.2
# Test that it work
(env_36) mint@mint ~ $ python
Python 3.6.1 (default, May 25 2017, 14:44:39)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> r = requests.get('http://www.python.org')
>>> r
<Response [200]>
>>> r.headers['date']
'Thu, 25 May 2017 16:59:22 GMT'