0

I believe that since I installed IPython Notebook via pip --user I now have two instances of each of Python, IPython and the other Python modules: the original instances that came with my Ubuntu system and the new local instances installed by pip.

$ which ipython
/usr/bin/ipython

$ cat /usr/bin/ipython
from IPython import start_ipython    
start_ipython()

Are the two ways of calling ipython (ipython and ~/.local/bin/ipython) equivalent?

2 Answers 2

0

No, IPythons is not a python version but a couple of utilities for Python. Mainly a improved command shell and the notebook. But you are using your regular python install.

You can install Ipython with it's own contained python version but this is not what pip does per default.

Pip can install packages locally if you give it the -user switch, if you did it, then you still have only one python installation, but with different libraries for different users.

Finally if you calling it with ~/.local/bin/ipython will probably run the user-level version of ipython instead of the system-level one (if you have both installed). If it runs that same thing or a different one than typing 'ipython' depends on your path.

4
  • I'm not very sure that this is clear enough, if you don't understand it ask and I try to clarify it. Believe it or not this started as a comment... Dec 4, 2014 at 7:58
  • thanks. Yes, I used pip with -user. The sentence " If it runs that same thing or a different one than typing 'ipython' depends on your path." is not clear indeed.
    – Valentas
    Dec 4, 2014 at 9:02
  • OK. "dpkg -s ipython" and "dpkg -s python-matplotlib" gave me versions lower than those I see when I run ipython or check matplotlib.__version__ or IPython.__version__. So I will assume the system Python somehow knows about and loads the newer packages from the local pip location.
    – Valentas
    Dec 4, 2014 at 9:15
  • Yes, you have one python install but two sets of libraries. System ipython will run the globally installed ones, ~/.local/bin/ipython will run your local ipython version using local libs when available and system ones when not. Dec 4, 2014 at 12:56
0

Are the two ways of calling ipython (ipython and ~/.local/bin/ipython) equivalent?

Short answer: no, they are not equivalent. Now lets see why:

Pip can install packages under a user's own home directory if you use it with the --user option, like you did. When you do this, it installs the package to ~/.local (note that this relative path gets expanded to something like /home/username/.local), however you still have only one global Python interpreter at /usr/bin/python. This makes the different libraries or modules that you install this way to only be accessible locally, which means that they aren't shared among users.

If you call any program with a relative or absolute path it will run whichever executable is located at the end of that path if it exists. In this case, the relative path ~/.local/bin/ipython points to a local instance of IPython.

When you call an executable by just typing its name, like ipython the PATH environment variable is used to determine what to run. So what actually runs will depend on its precedence in your PATH. This may or may not be the same executable as the one located at ~/.local/bin/ipython.

Use the which command to check what executable will be launched if you only type the name of a command: which ipython. It will give you the path to it.


Additionally, if you are already installing packages locally rather than system wide, I'd suggest you use virtual environments, it will make your life easier (most of the time), give virtualenv or venv a try.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.