简体   繁体   English

更改 Jupyter Notebook (Python3) 的环境

[英]Change environment for Jupyter Notebook (Python3)

Whenever I install package using pip on my computer, they are not available in my Jupyter Notebooks.每当我在我的计算机上使用 pip 安装 package 时,它们在我的 Jupyter Notebooks 中不可用。 From what I figured out, they are not in the same environment.据我了解,他们不在同一个环境中。 When I run当我跑

import sys
sys.executable

on the Notebook, I get在笔记本上,我得到

/Library/Developer/CommandLineTools/usr/bin/python3

while on the terminal I get在终端上我得到

/Library/Frameworks/Python.framework/Versions/3.7/bin/python3

What do I do to fix this?我该怎么做才能解决这个问题? All answers I found online assume conda in installed, but I do not use conda.我在网上找到的所有答案都假定已安装 conda,但我不使用 conda。 Ideally I would just change the default environment the Jupyter Notebook runs in but I can't figure out how...理想情况下,我只会更改 Jupyter Notebook 运行的默认环境,但我不知道如何...

EDIT编辑

I tried adding the environment as suggested in another article by using the following code in terminal:我尝试通过在终端中使用以下代码添加另一篇文章中建议的环境:

/Library/Frameworks/Python.framework/Versions/3.7/bin/python3 -m ipykernel install --prefix=/Library/Developer/CommandLineTools/usr/bin/python3 --name 'Py3’

But it returns但它返回

quote>

Which I don't really understand.我真的不明白。

You should change jupyter kernel via Kernel tab:您应该通过 Kernel 选项卡更改 jupyter kernel :

在此处输入图像描述

Use the explanation here if you want to add more kernels to jupyter: https://ipython.readthedocs.io/en/latest/install/kernel_install.html如果要向 jupyter 添加更多内核,请使用此处的说明: https://ipython.readthedocs.io/en/latest/install/kernel_install.html

Solved it by uninstalling Python 3 and then using homebrew and pyenv to install a new version in a more controlled manner and make it the system default.通过卸载 Python 3 然后使用 homebrew 和 pyenv 以更可控的方式安装新版本并使其成为系统默认值来解决它。 After a reboot it then worked.重新启动后,它就可以工作了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM