【发布时间】:2020-02-09 12:38:01
【问题描述】:
每次我在新计算机上安装 Anaconda 时,都会遇到这个环境设置问题。我正在使用 Mac 电脑。我成功安装了 Anaconda,但在运行 Jupyter Notebook 时仍然遇到问题。当我进入终端时,它开始时没有环境,当我输入 python 时,这是输出:
Last login: Fri Oct 11 22:47:17 on ttys000
username@Users-MacBook-Pro ~ % python
WARNING: Python 2.7 is not recommended.
This version is included in macOS for compatibility with legacy software.
Future versions of macOS will not include Python 2.7.
Instead, it is recommended that you transition to using 'python3' from within Terminal.
Python 2.7.16 (default, Aug 24 2019, 18:37:03)
[GCC 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.32.4) (-macos10.15-objc-s on darwin
Type "help", "copyright", "credits" or "license" for more information.
但是,我安装了 Anaconda 3.7,文件夹目录为:/Users/username/anaconda3。当我输入:source .bash_profile 时,这将激活 (base) 环境并让我打开 jupyter notebook。但是,我不想一直记住这个命令。相反,我希望能够输入jupyter notebook 并在我打开终端时打开它。可以请教一下吗?
谢谢!
【问题讨论】:
-
你用的是什么外壳?如果您使用
bash,.bash_profile将自动获取,但如果有其他情况,您需要为其运行特定的 init。例如,如果zsh,则运行一次conda init zsh将配置适当的初始化脚本。 -
@merv,效果很好。我什至不知道它使用的是
zsh。非常感谢! -
此外,在新版本的 anaconda 中,您需要输入
python3,即使您已激活虚拟环境(使用 Python3)。 -
@ScottSkiles 我以前从未听说过这个。您能否为此链接文档?
标签: python-3.x anaconda