Jupyter Notebook 和 Conda 命令行之间的软件包不一致。

huangapple go评论69阅读模式
英文:

Inconsistent packages between Jupyter Notebook and Conda Command Line

问题

  1. 为什么一个环境在 whoiam/opt/anaconda3,另一个在 whoiam/anaconda3

  2. 我应该更新 Jupyter Notebook 还是命令行路径?

  3. 如何更新其中一个路径?

  4. 我应该通过哪个来安装软件包以避免这个问题?

英文:

I just installed PyTorch and am trying to use it in my Jupyter Notebook. In the notebook, when I run conda list, I see the following:

# packages in environment at /Users/whoiam/opt/anaconda3:
#
# Name                    Version                   Build  Channel
_ipyw_jlab_nb_ext_conf    0.1.0                    py37_0  
alabaster                 0.7.12                   py37_0  
anaconda                  2019.10                  py37_0  
anaconda-client           1.7.2                    py37_0  
anaconda-navigator        1.9.7                    py37_0  
anaconda-project          0.8.3                      py_0 
...
python                    3.7.4                h359304d_1  
python-dateutil           2.8.0                    py37_0  
python-libarchive-c       2.8                     py37_13  
python.app                2                        py37_9  
pytz                      2019.3                     py_0 
...

But, in the command line of my terminal, I see this:

(base) whoiam@MacBook-Pro Downloads % conda list
# packages in environment at /Users/whoiam/anaconda3:
#
# Name                    Version                   Build  Channel
_ipyw_jlab_nb_ext_conf    0.1.0                    py37_0  
alabaster                 0.7.12                   py37_0  
anaconda                  2019.10                  py37_0  
anaconda-client           1.7.2                    py37_0  
anaconda-navigator        1.9.7                    py37_0  
anaconda-project          0.8.3                      py_0  
...
python                    3.7.4                h359304d_1  
python-dateutil           2.8.0                    py37_0  
python-libarchive-c       2.8                     py37_13  
python.app                2                        py37_9  
pytorch                   1.3.0                   py3.7_0    pytorch
pytz                      2019.3                     py_0  
...

I have a few questions:

  1. Why is one environment at whoiam/opt/anaconda3 and the other at whoiam/anaconda3?
  2. Should I be updating the Jupyter Notebook or the Command Line path?
  3. How do I update either path?
  4. Through which should I install packages to avoid this issue?

答案1

得分: 0

你应该创建并使用一个conda环境,而不是(base)

创建后,你应该通过Anaconda导航器或使用source activate yourenvname来激活这个环境。你会看到类似以下的内容:

(yourenvname) whoiam@MacBook-Pro Downloads

在终端中,如果你的名为yourenvname的环境被激活。

只有在这样做之后,你才能在终端中通过pip install来安装你的包,然后打开你的Jupyter笔记本,或直接在Jupyter笔记本中安装你的包。通过激活环境,你确保所有的包都在同一个且唯一的目录中。

英文:

You should create and use one conda enviroment other than (base).

After creating it, you should activate this env, through anaconda navigator or with source activate yourenvname. You will see something like:

(yourenvname) whoiam@MacBook-Pro Downloads

In the terminal, if your enviroment, with the name yourenvname is activated.

Only after doing this, you can install your packages via pip install in the terminal and then open you jupyter notebook, or directly install your packages in the jupyter notebook. By activating the env you ensure that all your packages are in the same and only directory.

答案2

得分: 0

在(base)命令行中运行Jupyter Notebook解决了我的问题:

在基础环境中执行jupyter notebook

英文:

Running jupyter notebook in (base) Command Line solved my problem:

Execute jupyter notebook in base.

huangapple
  • 本文由 发表于 2020年1月4日 12:00:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/59587761.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定