Last active
December 31, 2015 05:59
-
-
Save alexsavio/7944439 to your computer and use it in GitHub Desktop.
IPython notebooks on how to use Virtualenv and Virtualenvwrapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "Virtualenv" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": "# Virtualenv and virtualenvwrapper\n\n Install virtualenv and virtualenvwrapper\n \n sudo apt-get install python3-pip\n sudo pip3 install virtualenv virtualenvwrapper" | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": " Virtualenvwrapper .bashrc setup:\n\n echo \"export WORKON_HOME=~/envs\" >> .bashrc\n echo \"source /usr/local/bin/virtualenvwrapper.sh\" >> .bashrc\n echo \"export PIP_REQUIRE_VIRTUALENV=true\" >> .bashrc\n source ~/.bashrc\n" | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": "-PyCharm is a Python IDE with code assistance and analysis\nhttp://www.jetbrains.com/pycharm/download/index.html" | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": "## Basic usage commands\n\n Create a virtualenv:\n \n mkvirtualenv <env name>" | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": " Activate a virtualenv:\n \n workon <env name>" | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": " Install a package in the activated virtualenv \n\n pip install <package name>" | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": " Go to its directory when it is activated\n\n cdvirtualenv" | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": " Set a working directory as a project of the virtualenv\n\n cd <project dir>\n setvirtualenvproject $VIRTUAL_ENV $(pwd)" | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": " Get a list of the Python modules and versions installed in an activated virtualenv\n\n pip freeze" | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": " To deactivate a virtualenv\n\n deactivate" | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": "#### Run ipython within the virtualenv:\n\n echo -e alias ipy=\\\"python -c 'import IPython; IPython.terminal.ipapp.launch_new_instance()'\\\"\n ipy" | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": "#### Run ipython with other options:\n\n Add this to .bashrc:\n\n function ipyqt(){\n python -c 'import IPython; IPython.start_ipython(['\"'\"'qtconsole'\"'\"']);'\n }\n\n function ipynote(){\n python -c 'import IPython; IPython.start_ipython(['\"'\"'notebook'\"'\"']);'\n }" | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": "## REFERENCES:\n\n<http://www.virtualenv.org/en/latest/>\n\n<http://virtualenvwrapper.readthedocs.org/en/latest/>\n\n<http://virtualenvwrapper.readthedocs.org/en/latest/command_ref.html>\n\n<http://www.cs.dartmouth.edu/~nfoti/blog/blog/2012/07/17/setting-up-virtualenv-for-data-analysis-on-osx/>" | |
} | |
], | |
"metadata": {} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment