Skip to content
This repository has been archived by the owner on Mar 26, 2019. It is now read-only.

Zsh: command not found: jupyter #317

Closed
sudoankit opened this issue Mar 8, 2018 · 9 comments
Closed

Zsh: command not found: jupyter #317

sudoankit opened this issue Mar 8, 2018 · 9 comments

Comments

@sudoankit
Copy link

  • OS: macOS High Sierra 10.13.3 Beta (17D29a)
  • iTerm, zsh

After the python@2 rename by homebrew, jupyter (and also jupyter lab) doesn't work.

▶ jupyter
zsh: command not found: jupyter

I have done brew upgrade, installed and reinstalled python3 and python2 several times, created symlinks but still jupyter, jupyterlab don't work after the rename and migrations.

I use pip3 to install jupyter, not Anaconda.

Also, this is my $PATH:

▶ echo $PATH
/usr/local/Cellar/gcc/7.3.0:/usr/local/opt/python@2/libexec/bin:/usr/local/Cellar/python/3.6.4_3:/usr/local/lib:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/usr/local/go/bin:/opt/X11/bin:/usr/local/opt/python/libexec/bin:/Users/sudoankit/bin:/usr/local/Cellar

More details:

▶ which python3
/usr/local/bin/python3

▶ which python
/usr/local/opt/python@2/libexec/bin/python

▶ pip3 show jupyter
Name: jupyter
Version: 1.0.0
Summary: Jupyter metapackage. Install all the Jupyter components in one go.
Home-page: http://jupyter.org
Author: Jupyter Development Team
Author-email: jupyter@googlegroups.org
License: BSD
Location: /usr/local/lib/python3.6/site-packages
Requires: jupyter-console, ipywidgets, nbconvert, notebook, qtconsole, ipykernel

Note:

▶ ipython notebook
[TerminalIPythonApp] WARNING | Subcommand `ipython notebook` is deprecated and will be removed in future versions.
[TerminalIPythonApp] WARNING | You likely want to use `jupyter notebook` in the future
[I 12:59:59.770 NotebookApp] JupyterLab beta preview extension loaded from /usr/local/lib/python3.6/site-packages/jupyterlab
[I 12:59:59.770 NotebookApp] JupyterLab application directory is /usr/local/share/jupyter/lab
[I 12:59:59.779 NotebookApp] Serving notebooks from local directory: /Users/sudoankit

This works.

@sudoankit
Copy link
Author

So I found a workaround.

Installed Jupyter using brew : brew install jupyter

Now,

▶ jupyter-notebook
#Works!
▶ jupyter lab
#Doesn't work
▶ jupyter-lab
[I 18:43:57.920 LabApp] JupyterLab beta preview extension loaded from /usr/local/lib/python3.6/site-packages/jupyterlab
#works! yeah!

Problem fixed but still questions hover!

  1. How can I change Jupyter's path?
▶ jupyter --path
config:
    /Users/sudoankit/.jupyter
    /System/Library/Frameworks/Python.framework/Versions/2.7/etc/jupyter
    /usr/local/etc/jupyter
    /etc/jupyter
data:
    /usr/local/etc/jupyter
    /Users/sudoankit/Library/Jupyter
    /System/Library/Frameworks/Python.framework/Versions/2.7/share/jupyter
    /usr/local/share/jupyter
    /usr/share/jupyter
runtime:
    /Users/sudoankit/Library/Jupyter/runtime

I don't want it to use system python 2.7, I want it to use brew's python3.

  1. My notebook version is 5.0.0
▶ jupyter notebook --version
5.0.0

but if you use pip3 show notebook it's 5.4. ( if I could change Jupyter's path to point at python3 I think this would get solved! )

▶ pip3 show notebook
Name: notebook
Version: 5.4.0
Summary: A web-based notebook environment for interactive computing
Home-page: http://jupyter.org
Author: Jupyter Development Team
Author-email: jupyter@googlegroups.com
License: BSD
Location: /usr/local/lib/python3.6/site-packages
Requires: terminado, jinja2, nbformat, tornado, Send2Trash, jupyter-core, traitlets, jupyter-client, nbconvert, ipython-genutils, ipykernel

Also minor hiccups:

If I do:

▶ pip
Traceback (most recent call last):
  File "/usr/local/opt/python@2/libexec/bin/pip", line 11, in <module>
    load_entry_point('pip==9.0.1', 'console_scripts', 'pip2')()
  File "/Users/sudoankit/Library/Python/2.7/lib/python/site-packages/pkg_resources/__init__.py", line 587, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/Users/sudoankit/Library/Python/2.7/lib/python/site-packages/pkg_resources/__init__.py", line 2799, in load_entry_point
    raise ImportError("Entry point %r not found" % ((group, name),))
ImportError: Entry point ('console_scripts', 'pip2') not found

If I use pip2 ( as brew tells me: )

==> Caveats
This formula installs a python2 executable to /usr/local/opt/python@2/bin
If you wish to have this formula's python executable in your PATH then add
the following to ~/.zshrc:
  export PATH="/usr/local/opt/python@2/libexec/bin:$PATH"

Pip and setuptools have been installed. To update them
  pip2 install --upgrade pip setuptools

You can install Python packages with
  pip2 install <package>
▶ pip2
zsh: command not found: pip2

Weird.

@takluyver
Copy link
Member

How can I change Jupyter's path?

The bit you're looking at depends on the Python installation that it's running on. It looks like Homebrew has installed Jupyter on Python 2.7. I don't know if there's a way to tell Homebrew which Python to use, but the canonical way is to install it with pip: path/to/python3 -m pip install jupyter.

@sudoankit
Copy link
Author

It's strange brew is phasing away python2 slowly but still installs Jupyter on 2.7.

The canonical way (as I mention in the first post of this thread ) python3 -m pip install jupyter isn't working.

▶ python3 -m pip install jupyter
Requirement already satisfied: jupyter in /usr/local/lib/python3.6/site-packages

……and still I get:

▶ jupyter
zsh: command not found: jupyter

@takluyver
Copy link
Member

Try uninstalling Jupyter with every tool that might have installed it, and then installing again using pip. If some files have been removed or overwritten, pip won't necessarily notice that it should rewrite them.

@sudoankit
Copy link
Author

I finally fixed this by,

  1. Uninstalled jupyter using brew, brew uninstall jupyter.
  2. Using pip-purge which uninstalled every package I had.
  3. Installing again using pip3 install jupyter jupyterlab

That's it!

▶ jupyter --path
config:
    /Users/sudoankit/.jupyter
    /usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/etc/jupyter
    /usr/local/etc/jupyter
    /etc/jupyter
data:
    /Users/sudoankit/Library/Jupyter
    /usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/share/jupyter
    /usr/local/share/jupyter
    /usr/share/jupyter
runtime:
    /Users/sudoankit/Library/Jupyter/runtime

Everything is fine now. Thanks! @takluyver

@ckeshava
Copy link

ckeshava commented Jun 8, 2018

I had installed via the Anaconda installation. Anaconda will modify the $PATH at the end of ~/.bashrc file. I was facing the same issue. I added this line at the end of ~/.zshrc file:
export PATH="/home/chenna/anaconda3/bin:$PATH"
source ~/.zshrc
This worked for me.

@monktastic
Copy link

I'm having a similar problem. Couldn't get pip-purge to work, but explicitly pip uinstalled everything. After pip3 install jupyter, zsh still can't find it (because it doesn't exist).

@dennisja
Copy link

@chennakeshava1998 solution works and seems to be the best.

@jlave-dose
Copy link

jlave-dose commented Nov 8, 2018

If you installed Jupyter via the Anaconda graphical installer, Anaconda writes the following into your ~/.bash_profile:

# added by Anaconda3 5.3.0 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
    \eval "$__conda_setup"
else
    if [ -f "/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/anaconda3/etc/profile.d/conda.sh"
        CONDA_CHANGEPS1=false conda activate base
    else
        \export PATH="/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda init <<<

Just copy and paste that to the end of ~/.zshrc and run source .zshrc. Then zsh will look in your Anaconda path any time a shell is opened.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants