Skip to content

Instantly share code, notes, and snippets.

@bonfirefan
Last active June 4, 2018 23:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bonfirefan/c5556ca54e8bbe9d83764730c36a4b3e to your computer and use it in GitHub Desktop.
Save bonfirefan/c5556ca54e8bbe9d83764730c36a4b3e to your computer and use it in GitHub Desktop.
Basic instructions for setting up a virtual environment
  1. Install virtualenv and virtualenvwrapper:

sudo pip install virtualenv

sudo pip install virtualenvwrapper

  1. Create virtual environment folder

mkdir ~/.environments

  1. Edit your bash profile with vim to point to the newly created virtual environment folder.
echo "export WORKON_HOME=~/.environments" >> ~/.bashrc
source /usr/local/bin/virtualenvwrapper.sh
  1. Source your bash profile

source ~/.bashrc

  1. Test run mkvirtualenv. Create new environments in python 3 with
mkvirtualenv -p `which python3` city-scrapers
  1. Check your virtual environment folder for the newly created virtual environment

  2. To activate the environment, type workon your-env-name. To exit, type deactivate

@emmanuellyautomated
Copy link

emmanuellyautomated commented Apr 5, 2018

🤔 rather than modifying the ./bashrc and using mkvirtualenv, one could also place their ./environments/ directory in the same directory as the project. The following steps would do the trick:

  • cd <wherever-you-cloned-it>/city-scrapers/
  • virtualenv -p python3.6 venv
  • source venv/bin/activate

Then if you run which python, it should contain the path for the current directory.

@cherdeman
Copy link

For mac users, your bash profile might be located at vi ~/.bash_profile or nano .bash_profile to use the linux text editor. If that works for you, then you'll also need to run source ~/.bash_profile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment