Search code examples
python-3.xipythonzsh

IPython Seems to Be Installed But Won't Run


It seems to me that iPython is already installed because when I install it I am getting "Requirement already satisfied"... messages. However, when I go to launch it by typing ipython I get the following:

> Defaulting to user installation because normal site-packages is not
> writeable Requirement already satisfied: ipython in
> ./Library/Python/3.11/lib/python/site-packages (8.23.0) Requirement
> already satisfied: decorator in
> ./Library/Python/3.11/lib/python/site-packages (from ipython) (5.1.1)
> Requirement already satisfied: jedi>=0.16 in
> ./Library/Python/3.11/lib/python/site-packages (from ipython) (0.19.1)
> Requirement already satisfied: matplotlib-inline in
> ./Library/Python/3.11/lib/python/site-packages (from ipython) (0.1.6)
> Requirement already satisfied: prompt-toolkit<3.1.0,>=3.0.41 in
> ./Library/Python/3.11/lib/python/site-packages (from ipython) (3.0.43)
> Requirement already satisfied: pygments>=2.4.0 in
> ./Library/Python/3.11/lib/python/site-packages (from ipython) (2.17.2)
> Requirement already satisfied: stack-data in
> ./Library/Python/3.11/lib/python/site-packages (from ipython) (0.6.3)
> Requirement already satisfied: traitlets>=5.13.0 in
> ./Library/Python/3.11/lib/python/site-packages (from ipython) (5.14.2)
> Requirement already satisfied: typing-extensions in
> ./Library/Python/3.11/lib/python/site-packages (from ipython) (4.11.0)
> Requirement already satisfied: pexpect>4.3 in
> ./Library/Python/3.11/lib/python/site-packages (from ipython) (4.9.0)
> Requirement already satisfied: parso<0.9.0,>=0.8.3 in
> ./Library/Python/3.11/lib/python/site-packages (from
> jedi>=0.16->ipython) (0.8.4) Requirement already satisfied:
> ptyprocess>=0.5 in ./Library/Python/3.11/lib/python/site-packages
> (from pexpect>4.3->ipython) (0.7.0) Requirement already satisfied:
> wcwidth in ./Library/Python/3.11/lib/python/site-packages (from
> prompt-toolkit<3.1.0,>=3.0.41->ipython) (0.2.13) Requirement already
> satisfied: executing>=1.2.0 in
> ./Library/Python/3.11/lib/python/site-packages (from
> stack-data->ipython) (2.0.1) Requirement already satisfied:
> asttokens>=2.1.0 in ./Library/Python/3.11/lib/python/site-packages
> (from stack-data->ipython) (2.4.1) Requirement already satisfied:
> pure-eval in ./Library/Python/3.11/lib/python/site-packages (from
> stack-data->ipython) (0.2.2) Requirement already satisfied:
> six>=1.12.0 in ./Library/Python/3.11/lib/python/site-packages (from
> asttokens>=2.1.0->stack-data->ipython) (1.16.0) heather@C02H55GGQ05F ~
> % ipython zsh: command not found: ipython

What am I missing friends? Thanks in advance!


Solution

  • Since using python3.11 -m IPython works, it means the user installation was successful in your python3.11 runtime. However, for the ipython command to work, the scripts path (where the ipython executable should be found) needs to be present on the $PATH environment variable.

    The location of the scripts path is platform-dependent, but can be found within Python using:

    import sysconfig
    print(sysconfig.get_path("scripts"))
    

    Append this location to the $PATH var with something like this in your shell:

    export PATH=~/.local/bin:$PATH   
    # linux/macOS.
    # use "set" instead of "export" for windows.
    

    You may also want to append the path in your shell init files, e.g. in ~/.zshrc.