Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
vms:python:dev [2017/03/31 19:54]
admin [Virtual Environments]
vms:python:dev [2017/04/14 00:28]
admin [Virtualenvwrapper]
Line 59: Line 59:
 Notice that ''​python''​ and ''​python2''​ are the same, this is also true for ''​pip''​ and ''​pip2''​. Notice that ''​python''​ and ''​python2''​ are the same, this is also true for ''​pip''​ and ''​pip2''​.
 ===== Virtual Environments ===== ===== Virtual Environments =====
 +[[http://​joebergantine.com/​blog/​2015/​apr/​30/​installing-python-2-and-python-3-alongside-each-ot/​]]
  
-Virtual Environments are used to isolate ​project ​python versions and package dependencies.+Virtual Environments are used to isolate python versions and package dependencies ​for each specific project.
  
-As stated before, we'll install ''​virtualenv''​ for User only in order to allow coexistence of Python2 and Python3. As the virtualenv binary will bear the same name for 2 & 3, we'​ll ​rename ​them on the go:+We'll install ''​virtualenv''​ for User only in order to allow coexistence of Python2 and Python3. As the virtualenv binary will bear the same name for 2 & 3, we'​ll ​move them on the go:
  
 === Virtualenv 2 === === Virtualenv 2 ===
Line 72: Line 73:
 ADD: ADD:
 # Python virtualenv # Python virtualenv
-alias virtualenv3="​~/​.local/​lib/​python2.7/​bin/​virtualenv"​+alias virtualenv2="​~/​.local/​lib/​python2.7/​bin/​virtualenv"​
  
 > source ~/.bashrc > source ~/.bashrc
Line 84: Line 85:
 > source env_name/​bin/​activate > source env_name/​bin/​activate
 > cd env_name > cd env_name
 +[> deactivate]
 </​Code>​ </​Code>​
  
Line 100: Line 102:
 <​Code>​ <​Code>​
 > pip3 install --user virtualenv > pip3 install --user virtualenv
 +> mv ~/​.local/​bin ~/​.local/​lib/​python3.4/​
 > nano ~/.bashrc > nano ~/.bashrc
 ADD: ADD:
 alias virtualenv3='​~/​.local/​lib/​python3.4/​bin/​virtualenv'​ alias virtualenv3='​~/​.local/​lib/​python3.4/​bin/​virtualenv'​
  
-> source .bashrc+> source ​~/.bashrc
 > virtualenv3 --version > virtualenv3 --version
 15.1.0 15.1.0
 </​Code> ​ </​Code> ​
  
 +==== Virtualenvwrapper ====
 +
 +[[https://​virtualenvwrapper.readthedocs.io/​en/​latest/​]]
 +
 +=== Installation & Configuration ===
 +
 +Install virtualenvwrapper for python3 for the user only:
 +<​Code>​
 +> pip3 install --user virtualenvwrapper
 +> mv ~/​.local/​bin/​* ~/​.local/​lib/​python3.4/​bin/​
 +> rm ~/​.local/​bin
 +> mkdir projects
 +> nano .bashrc
 +ADD:
 +
 +# VirtualenvWrapper
 +export WORKON_HOME=$HOME/​.virtualenvs
 +export PROJECT_HOME=$HOME/​projects
 +export VIRTUALENVWRAPPER_PYTHON=/​usr/​bin/​python3
 +export PATH=~/​.local/​lib/​python3.4/​bin:​$PATH
 +source $HOME/​.local/​lib/​python3.4/​bin/​virtualenvwrapper.sh
 +
 +> source .bashrc
 +virtualenvwrapper.user_scripts creating /​home/​dev/​.virtualenvs/​premkproject
 +...
 +...
 +virtualenvwrapper.user_scripts creating /​home/​dev/​.virtualenvs/​get_env_details
 +
 +> mkvirtualenv temp
 +Using base prefix '/​usr'​
 +New python executable in /​home/​dev/​.virtualenvs/​temp/​bin/​python3
 +Also creating executable in /​home/​dev/​.virtualenvs/​temp/​bin/​python
 +Installing setuptools, pip, wheel...done.
 +...
 +...
 +(temp) >
 +</​Code>​
 +
 +=== Projects management ===
 +
 +[[https://​virtualenvwrapper.readthedocs.io/​en/​latest/​projects.html#​project-management]]
 +
 +===== Django =====
 +
 +[[http://​wiki.strategicz.com/​vhyper/​doku.php?​id=vms:​python:​django]]