I'm following a tutorial called Starting a Django 1.4 Project the Right Way, which gives directions on how to use virtualenv and virtualenvwrapper, among other things.
There's a section that reads:
If you're using pip to install packages (and I can't see why you wouldn't), you can get both virtualenv and virtualenvwrapper by simply installing the latter.
$ pip install virtualenvwrapper
After it's installed, add the following lines to your shell's start-up file (.zshrc, .bashrc, .profile, etc).
export WORKON_HOME=$HOME/.virtualenvs export PROJECT_HOME=$HOME/directory-you-do-development-in source /usr/local/bin/virtualenvwrapper.sh
Reload your start up file (e.g. source .zshrc) and you're ready to go.
I am running Mac OSX, and don't know my way around the Terminal too well. What exactly does the author mean by shell's start-up file (.zshrc, .bashrc, .profile, etc)
? Where do I find this file, so that I can add those three lines?
Also, what does he mean by reload your start up file (e.g. source .zshrc)
?
I would appreciate a detailed response, specific to OSX.
An interactive login shell is started after a successful login, using /bin/login , by reading the /etc/passwd file. This shell invocation normally reads /etc/profile and its private equivalent ~/. bash_profile (or ~/. profile if called as /bin/sh) upon startup.
system-wide startup files – theses contain global configurations that apply to all users on the system, and are usually located in the /etc directory. They include: /etc/profiles and /etc/bashrc or /etc/bash.
Use Shell preferences in Terminal to change the startup or exit behavior of the shell for a Terminal window profile. To change these preferences in the Terminal app on your Mac, choose Terminal > Preferences, click Profiles, select a profile, then click Shell.
In the Run command field, type shell: startup and then press Enter key to open Startup folder. (Figure 3.0: Run Command Box) Copy and paste the app shortcut from the desktop to this Startup folder and the app will be added to startup.
You're probably using bash
so just add these 3 lines to ~/.bash_profile
:
$ cat >> ~/.bash_profile export WORKON_HOME=$HOME/.virtualenvs export PROJECT_HOME=$HOME/directory-you-do-development-in source /usr/local/bin/virtualenvwrapper.sh ^D
where ^D
means you type Control+D (EOF).
Then either close your terminal window and open a new one, or you can "reload" your .bash_profile
like this:
$ source ~/.bash_profile
If you use bash, it usually means ~/.bash_profile
.
In Terminal and iTerm new shells are login shells by default, so ~/.bashrc
is not read at all. If instructions written for some other platform tell you to add something to .bashrc
, you often have to add it to .bash_profile
instead.
If both ~/.profile
and ~/.bash_profile
exist, only .bash_profile
is read. .profile
is also read by other shells, but many of the things you'd add to .bash_profile
wouldn't work with them.
From /usr/share/doc/bash/bash.html:
When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file
/etc/profile
, if that file exists. After reading that file, it looks for~/.bash_profile
,~/.bash_login
, and~/.profile
, in that order, and reads and executes commands from the first one that exists and is readable.[...]
When an interactive shell that is not a login shell is started, bash reads and executes commands from
~/.bashrc
, if that file exists.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With