更改路径以修复 Mac OSX:` -bash: jupyter: command not found`?

Changing paths to fix Mac OSX:` -bash: jupyter: command not found`?

此问题之前已在 SO 上讨论过,但建议的修复方法无效。

我已经用 pip install jupyter --upgrade 和 macports port install py34-jupyter 安装了 Jupyter,但我无法通过命令行访问命令 jupyter

执行pip install jupyter时,信息为:

Requirement already satisfied: jupyter in /opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages

这也是pip所在的地方。我也试过

pip uninstall notebook
pip install notebook --upgrade

但这没有用。

/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages 内,我看到:

jupyter-1.0.0-py3.4.egg-info
jupyter-1.0.0.dist-info
jupyter.py
jupyter_client
jupyter_client-4.4.0-py3.4.egg-info
jupyter_client-4.4.0.dist-info
jupyter_console
jupyter_console-5.0.0-py3.4.egg-info
jupyter_console-5.0.0.dist-info
jupyter_core
jupyter_core-4.2.0.dist-info
jupyter_core-4.2.1-py3.4.egg-info

我认为命令 jupyter 可能没有必要的可执行文件的正确路径,但事实并非如此。

我怎样才能访问 jupyter notebook

如果您在 mac 上使用 python,我强烈建议您使用 virtualenv 并使用它安装所有依赖项。在安装和使用多个库时遇到问题。

pip install virtualenv virtualenvwrapper
# Create a backup of your .bash_profile
cp ~/.bash_profile ~/.bash_profile-org

# Be careful with this command
printf '\n%s\n%s\n%s' '# virtualenv' 'export WORKON_HOME=~/virtualenvs' \
'source /usr/local/bin/virtualenvwrapper.sh' >> ~/.bash_profile

source ~/.bash_profile

mkdir -p $WORKON_HOME

mkvirtualenv your_virtual_env

这将创建虚拟环境

deactivate

当您离开虚拟环境时,您可以使用 pip uninstall jupyter

从 machine 中卸载 jupyter
workon your_virtual_env
pip install jupyter