Reputation: 53
I have been using python 3 on OS X for ~6 months now and have recently been turned onto iPython. I have installed some python packages using the pip install tool as follows:
python3.6 -m pip install matplotlib
I installed iPython (running python3.6) using the pip install tool as well, however, once in iPython, the packages previously installed are not recognized. I'm sure there is a way to 'point' iPython to the locations of the packages, I just don't know what it is. I know this is a basic question, but any help would be appreciated.
Upvotes: 1
Views: 1086
Reputation: 363043
It is possible for this to occur when you have multiple versions of Python on your system.
The cause:
The setup for IPython is somewhat a mess (as is Python packaging in general), and you may not be interested in the details of how it gets into a screwed up state so I'll keep it brief: the "ipython" command is really just a plain old python script with a shebang. It's created by the installer console_scripts
.
pip
monkeypatches setuptools
which monkeypatches distutils
which munges the shebang at install time: here.
The solution:
Find which Python interpreter is bound to your console script, something like this:
$ head -1 $(which ipython)
#!/usr/bin/python3
Use that interpreter to uninstall IPython, something like this:
$ /usr/bin/python3 -m pip uninstall ipython
Re-install IPython for the interpreter you want, something like this:
$ python3.6 -m pip install ipython
Bonus: If you want to use ipython with both a system level Python 2 interpreter and a system level Python 3 interpreter, consider setting up aliases in your bashrc or similar:
alias ipython2="python2 /path/to/ipython"
alias ipython3="python3 /path/to/ipython"
You can do similar with pip2
and pip3
. Note that ipython has dropped support for Python 2 in v6.0, but it is quite fine to have both ~=5.6
installed in Python 2's site-packages and latest installed in Python 3's site-packages.
Upvotes: 1