0
votes

As shown in the following snippets - the paths point for python and ipython seem to all point to 3.x- however the result is launching 2.x. I am on macos High Sierra Any thoughts?

  • Which python are we using (3.X):

    which python /usr/local/bin/python

    $python --version Python 3.6.4

  • Which python is ipython pointing to (3.X ?)

    cat  $(which ipython)
    #!/usr/local/bin/python

    import re
    import sys

    from IPython import start_ipython

    if __name__ == '__main__':
        sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
        sys.exit(start_ipython())
  • So let's run ipython - and then which python version is launched (2.X ??):

    $ipython Python 2.7.15 (default, Jun 26 2018, 09:40:54) Type "copyright", "credits" or "license" for more information.

    IPython 5.5.0 -- An enhanced Interactive Python.

Update There was a comment about ipython3: I had looked into that as well before posting. After running

pip3 install ipython

the results were Requirement already satisfied for all dependencies. Afterwards however ipython3 still does not appear in the $PATH.

2
try ipython3! - DarkSuniuM
there is no ipython3 in the $PATH - I had checked that earlier. - WestCoastProjects
you can install both ipython3 and ipython using apt ( if you're using a debian base distro ), the only time that ipython uses python3 is when u are running it inside a virtualenv that has been created using python3, try sudo apt install ipython3 && pip3 install ipython - DarkSuniuM
btw I am on macos: updated the question. - WestCoastProjects

2 Answers

0
votes

While the following is not - by far - an optimal solution it is a workaround for now:

alias ipython3='python3 -m IPython'

Multiple questions from the OP still remain as to why the various PATH elements are not working as expected.

0
votes

You either need to change the PATH or use a virtual environment.

If you do not want to use conda you can use virtualenv.

You can install this with $ pip install virtualenv. Make sure you install it for the right Python version.

After that you can create a virtual environment by creating a folder and then executing python3 -m venv env

You activate the environment in your shell / console with the source env/bin/activate command.

If the command is successful your shell will show the environment in brackets.

Every virtual environment will have it's own set of packages but packages that you installed globally will be available when you built the environment.

This will work under Linux and Windows. Keep in mind that Windows does not have a shell.

Here is a full primer.