I am running into some issues with installing python
modules while using python
versus ipython
and I think it has to do with my .profile
and .bash_profile
.
My desired setup is to be able to leverage homebrew
, pip
and easy_install
to install programs and modules, and have them install into the correct location so python
and ipython
point to the same source. Here is the output of which
for various programs:
mike$ which brew
/usr/local/bin/brew
mike$ which ruby
/usr/bin/ruby
mike$ which python
/usr/local/bin/python
mike$ which ipython
/usr/local/share/python/ipython
.profile
output:
PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
.bash_profile
output:
if [ -f ~/.bashrc ]; then source ~/.bashrc ; fi
export PATH=/usr/local/share/python:$PATH
What changes should I make so that when I install modules or programs, they automatically go into the correct location?
Your
PATH
tells bash which executables to run when you type a certain command, not which modules to load in python. You can check where modules are installed by doing:You're problem is likely due to either running different versions of python or having ipython use a different
PYTHONPATH
. Try doing:in the two different interpreters. If it raises a KeyError, then try setting
PYTHONPATH
in your .bash_profile to the libraries you want, e.g.:If it's a version issue, then use the appropriate pip command (e.g.
pip-2.7
- see pip: dealing with multiple Python versions?). The same applies for easy_install.For ruby I recommend using
rvm
andgem install
(steps 6-8 of http://www.moncefbelyamani.com/how-to-install-xcode-homebrew-git-rvm-ruby-on-mac/). These tools are similar to python's pip and easy_install, allowing for seamless installation of ruby gems.