0

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.

4
  • try ipython3!CommentedSep 2, 2018 at 16:23
  • there is no ipython3 in the $PATH - I had checked that earlier.CommentedSep 2, 2018 at 17:15
  • 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 ipythonCommentedSep 2, 2018 at 17:52
  • btw I am on macos: updated the question.CommentedSep 2, 2018 at 17:54

2 Answers 2

0

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

    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.

    3
    • There are reasons why I am not using virtualenv. If you can identify why the PATH is not working properly (for native python3/ipython3) that would be appreciated.CommentedSep 2, 2018 at 17:36
    • Are you using Linux or Windows? If windows then you have to explicitly set a hook in the installer if you want to change the path on installation. It is possible that other programs/tools still need python2. If you can make absolutely sure that this is not the case then you can simply change the PATH. However the virtual environments are exactly made for your problem/scenario. Is there are reason why you can't use them?CommentedSep 2, 2018 at 17:41
    • I don't want to go into the reasons why I am not using a virtualenv (/conda , etc). They have all been looked at (and tried) multiple times and are no less problematic. I am on macosCommentedSep 2, 2018 at 17:52

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.