lio*_*hem 3 python jupyter jupyter-notebook
对于我的作业,我们需要使用 jupyter 笔记本来运行 .ipynb 文件。我用的是Mac,以前都是pip install jupyter用终端安装的,成功了。但是,当我尝试使用命令打开它时,jupter notebook出现此错误。有任何想法吗?谢谢。

回溯(最近一次调用最后):文件“/Library/Frameworks/Python.framework/Versions/3.6/bin/jupyter-notebook”,第5行,来自notebook.notebookapp导入主文件“/Library/Frameworks/Python.framework” /Versions/3.6/lib/python3.6/site-packages/notebook/notebookapp.py”,第 76 行,来自 .base.handlers 导入 Template404,RedirectWithParams 文件“/Library/Frameworks/Python.framework/Versions/3.6/ lib/python3.6/site-packages/notebook/base/handlers.py”,第 24 行,导入 prometheus_client 文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ prometheus_client/ init .py”,第 3 行,来自 . 导入(文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/gc_collector.py”,第43行,在GC_COLLECTOR = GCCollector()文件“/Library/Frameworks/ Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/gc_collector.py”,第 14 行,initregistry.register (self) 文件“/Library/Frameworks/Python.framework/Versions/3.6 /lib/python3.6/site-packages/prometheus_client/registry.py”,第 26 行,寄存器名称 = self._get_names(collector) 文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3. 6/site-packages/prometheus_client/registry.py”,第 66 行,在 desc_func() 中的 _get_names 中获取度量:文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ prometheus_client/gc_collector.py”,第 36 行,在收集 Collected.add_metric([ Generation], value=stat['collected']) 文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ site-packages/prometheus_client/metrics_core.py",第 126 行,在 add_metric self.samples.append(Sample(self.name + '_total', dict(zip(self._labelnames, labels)), value, timestamp)) TypeError : new () 缺少 1 个必需的位置参数:'exemplar'
从你的终端屏幕截图中,我可以看到你不在虚拟环境中,这意味着你正在使用全局 python。
为了避免您所看到的错误类型 - 创建 Python 版本的依赖性问题,最好使用像 conda 这样的包管理器或使用虚拟环境并在其中安装。
如果您不想使用 vnev 或像 conda 这样的包管理器,请仔细检查您是否安装了正确的 python 版本,并在您想要使用的 python 版本上安装 jupyter。
python3.6 -m pip install jupyter
Run Code Online (Sandbox Code Playgroud)
有许多不同的选项可用于管理 python 版本,有些人喜欢在当前工作目录中创建虚拟环境并使用以下命令激活它们:
python3.6 -m pip install virtualenv
python3.6 -m venv env_name
source env_name/bin/activate
Run Code Online (Sandbox Code Playgroud)
激活后,您的终端将显示:
(env_name) jeffmpro....
Run Code Online (Sandbox Code Playgroud)
然后,您可以在此环境中 pip install jupyter,然后将使用以下命令运行:
jupyter notebook
Run Code Online (Sandbox Code Playgroud)
如果你想使用 shims 全局管理 python 版本和虚拟环境,你可以使用一个名为 pyenv 的包来做到这一点:
https://github.com/pyenv/pyenv
https://github.com/pyenv/pyenv-virtualenv
我还会在 mac 上使用 homebrew 来管理命令行中的安装。
希望这可以帮助 :-)
| 归档时间: |
|
| 查看次数: |
3491 次 |
| 最近记录: |