I have Ipython installed but it runs on python 2.7.5 , I also have python 3.3 installed. How can I make changes such that Ipython runs on python 3.3 not 2.7.5?
-
Packages are installed separately on each Python installation you have. You just need to install IPython using Python 3 - e.g. `python3 setup.py install`. – Thomas K Jan 27 '14 at 18:14
-
Doesn't work. IPython seems to need a python.exe for installation and for mine that's 2.7.5 -bash: /usr/local/bin/pip: /usr/bin/python: bad interpreter: No such file or directory – ROBOTPWNS Jan 27 '14 at 19:18
-
python.exe? On a Mac? `.exe` is a Windows extension. If you have Python 3.3 installed, then you must have some command on your system that you can use to run it. – Thomas K Jan 27 '14 at 19:58
1 Answers
You need to install pip
for Python 3 - it's as easy as going to the pip-installer.org
Installation page and following the instructions. Briefly, download get-pip.py
and save it someplace, like your Downloads
folder. Navigate there in Terminal, and run
sudo python3 get-pip.py
and you should soon have either a pip3
or pip-3.3
command (maybe both, I don't remember). You should now be able to run
sudo pip3 install ipython[all]
and hopefully all the dependencies will be installed as well. If installation chokes, use pip3
to install pyzmq
, tornado
, pyreadline
, jinja2
, pygments
, and maybe a few others. Make sure you read the docs before you start, so you have an idea of what you're trying to achieve. IPython is large and quite complex, with many moving parts, so in the absence of a package manager (see below) it can take a bit of time before everything is up and running.
The Package Manager Way
There are other options, too. You can install Anaconda, a "Completely free enterprise-ready Python distribution for large-scale data processing, predictive analytics, and scientific computing" with over 100 packages, including IPython and its dependencies. By default, the Anaconda installer gives you Python 2.7, but you can use the conda
command to install Python 3.
My personal favorite is to install Python 3 and IPython using MacPorts. Yes, it'll install Py3 all over again, but unless you're really starving for disk space (in which case you probably don't want to be installing large packages like IPython) it's no big deal. Using the port
command, once the base MacPorts installation has been put in place, you can just run
sudo port install py33-ipython +pyqt4
and all the other dependencies will be taken care of, (hopefully) flawlessly, without your having to do anything else except wait for a long time while things like PyQt are compiled. You may also need to run sudo port install py33-ipython +notebook
if you want the notebook, I don't recall if it's installed otherwise. BTW, you do need X11, Xcode, and the Xcode command-line tools for MacPorts, but they would likely be required if you do the first option as not all packages have binaries available for OS X. The excellent documentation walks you through everything, from installation to using the port
command to maintaining your system. I would highly recommend modifying your ~/.profile
(or ~/.bash_profile
, ~/.bashrc
, or equivalent for your shell) to add the MacPorts install directories (/opt/local/bin
and /opt/local/sbin
, by default) to the front of your path. Just add export PATH='/opt/local/bin:/opt/local/sbin:$PATH'
to the end of the file.
A third alternative option is to use Homebrew. It's similar to MacPorts, in that the brew
command is a type of package manager like port
and conda
, but in my experience it doesn't have as many packages, and doesn't quite work as seamlessly as port
. However, my observations on StackOverflow, Ask Different and other fora seem to indicate that about 50% of people have great experiences with brew
and don't like port
, while the other half loves port
over brew
. YMMV.
I hope this helps. Good luck with your installation!
-
-
WooHoo -- no more `from __future__ import division` after I open my ipython console! – Eric Wilson Jan 21 '15 at 13:57
-
1@EricWilson if there are other options you'd like to set up on IPython startup (default imports, custom functions, etc.), check out [this answer](http://stackoverflow.com/a/20889802/1426065) (also mine). The path given is for Windows, but for OS X/Linux it's `~/.ipython/...`. For example, mine contains imports for `matplotlib`, `numpy`, and `pandas`, and defines a few custom functions I use frequently, like pretty printing dicts and lists. It's quite helpful. – MattDMo Jan 21 '15 at 15:52