gpt4 book ai didi

python - 无法使用 anaconda 从 jupyter notebook 导入水印

转载 作者:太空宇宙 更新时间:2023-11-03 12:00:52 25 4
gpt4 key购买 nike

我看到我安装了水印:

(testenv) ➜  ~ conda install watermark
Fetching package metadata ...........
Solving package specifications: .

# All requested packages already installed.
# packages in environment at /Users/myuser/anaconda3/envs/testenv:
#
watermark 1.5.0 py36_0 conda-forge
(testenv) ➜ ~

然后我运行 jupyter notebook 它启动了:

(testenv) ➜  ~ jupyter notebook
[I 11:30:56.897 NotebookApp] JupyterLab alpha preview extension loaded from /Users/myuser/anaconda3/lib/python3.6/site-packages/jupyterlab
JupyterLab v0.27.0
Known labextensions:
[I 11:30:56.899 NotebookApp] Running the core application with no additional extensions or settings
[I 11:30:56.905 NotebookApp] Serving notebooks from local directory: /Users/myuser
[I 11:30:56.905 NotebookApp] 0 active kernels
[I 11:30:56.905 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/?token=a17e10f9a22d9bbee4bc55d24741c56408278254edb57a22
[I 11:30:56.905 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 11:30:56.909 NotebookApp]

Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=a17e10f9a22d9bbee4bc55d24741c56408278254edb57a22
[I 11:30:57.152 NotebookApp] Accepting one-time-token-authenticated connection from ::1

但是当我在 jupyter 中运行时,我无法导入水印,我做错了什么吗?

from __future__ import print_function
from distutils.version import LooseVersion as Version
import sys

importlib.import_module('watermark')

---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-6-b1c6f1862f9d> in <module>()
3 import sys
4
----> 5 importlib.import_module('watermark')

~/.pyenv/versions/3.6.4rc1/lib/python3.6/importlib/__init__.py in import_module(name, package)
124 break
125 level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)
127
128

~/.pyenv/versions/3.6.4rc1/lib/python3.6/importlib/_bootstrap.py in _gcd_import(name, package, level)

~/.pyenv/versions/3.6.4rc1/lib/python3.6/importlib/_bootstrap.py in _find_and_load(name, import_)

~/.pyenv/versions/3.6.4rc1/lib/python3.6/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_)

ModuleNotFoundError: No module named 'watermark'

最佳答案

#Step 1: In teminal

conda install -c conda-forge watermark

#Step 2: In Jupyter Notebook
import sys
!conda install --yes --prefix {sys.prefix} watermark

关于python - 无法使用 anaconda 从 jupyter notebook 导入水印,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48528127/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com