Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fail to import watermark from jupyter notebook with anaconda

I see I have watermark installed:

(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) ➜  ~

I then run jupyter notebook it starts up:

(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

But when I run in jupyter I can't import watermark, anything i'm doing wrong?

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'
like image 465
Jas Avatar asked Nov 08 '22 11:11

Jas


1 Answers

#Step 1: In teminal

conda install -c conda-forge watermark

#Step 2: In Jupyter Notebook
 import sys
 !conda install --yes --prefix {sys.prefix} watermark
like image 62
Tomás Tapia Barría Avatar answered Nov 14 '22 22:11

Tomás Tapia Barría