question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

importing a specific libs prevent the output display

See original GitHub issue

Descripsion

As you can see on the image provided a normal jupyter-execute prints work but when I import my lib (sepal_ui), I get this strange display ending by "\n "}}}, "version_major": 2, "version_minor": 0}.

It seems related to https://github.com/jupyter-widgets/ipywidgets/issues/1305 but I don’t get how it is link to this repository. Did someone already experiment this error and can tell me what’s wrong in my lib ?

screenshot

Capture d’écran 2021-09-10 à 15 25 13

steps to reproduce

create a new project:

mkdir docs
cd docs 
sphinx-quickstart

then update your environment with the sepal_uilib:

pip install sepal_ui

update conf.py:

# conf.py
# [...]

extensions = [
    'jupyter_sphinx',
]

# [...]

update index.rst:

.. jupyter-execute::
    
    print('hello ')

.. jupyter-execute::

    from sepal_ui import sepalwidgets as sw

build it and watch the produced single html page

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
12rambaucommented, Sep 10, 2021

I would be happy to contribute !

A first and easy fix is the replace </script> by &lt/scrip>because it’s in the end the only one that can cause trouble but i don’t know if it can have any other consequences in the lib

0reactions
12rambaucommented, Sep 10, 2021

https://stackoverflow.com/questions/22488830/script-within-a-javascript-string-in-a-script-tag

https://stackoverflow.com/questions/1061697/whats-the-easiest-way-to-escape-html-in-python

from what I understand the only one that can interact is </script> as everything is included in a <script> tag. I experimented also with escape and it also work I’m just not sure it’s necessary.

For my small usecase it works and everything is displayed as expected on screen.

edit

If the output cell include “<” or “>” I don’t think we want them to be escaped so a dedicated replace seems to be the safest to me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

suppress output on library import in python - Stack Overflow
I'd rather not touch the library, as I need to just suppress the output on one particular script and the library is used...
Read more >
Python import: Advanced Techniques and Tips
The Python import system is as powerful as it is useful. In this in-depth tutorial, you'll learn how to harness this power to...
Read more >
importlib — The implementation of import — Python 3.11.1 ...
A legacy method which when implemented calculates and returns the given module's representation, as a string. The module type's default __repr__() will use...
Read more >
Secure loading of libraries to prevent DLL preloading attacks
Provides guidance for software developers that design applications that dynamically load DLLs without specifying a fully qualified path name.
Read more >
Importing Existing Libraries to Your Connected Workspace in ...
In the Components panel, choose the Import Library option from the. menu. If a database or file-based library is currently selected in the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found