Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest PyScript REPL not showing results #1147

Closed
3 tasks done
radiantone opened this issue Feb 4, 2023 · 14 comments
Closed
3 tasks done

Latest PyScript REPL not showing results #1147

radiantone opened this issue Feb 4, 2023 · 14 comments
Labels
classic Issues only applicable to PyScript versions 2023.05.1 and earlier ("PyScript Classic") needs-triage Issue needs triage type: bug Something isn't working

Comments

@radiantone
Copy link

Checklist

  • I added a descriptive title
  • I searched for other issues and couldn't find a solution or duplication
  • I already searched in Google and didn't find any good information or help

What happened?

I was previously using alpha pyscript but when I switched to latest
https://pyscript.net/latest/pyscript.js

Suddenly my REPL component is not printing the output when I press the green run button. The correct output is printed in the browser console but not in my

.

What browsers are you seeing the problem on? (if applicable)

Chrome

Console info

[pyscript/main] Packages to install:  []
logger.ts:39 [pyscript/main] Paths to fetch:  []
logger.ts:39 [pyscript/main] All paths fetched
logger.ts:39 [pyscript/main] Python plugins to fetch:  []
logger.ts:39 [pyscript/main] All plugins fetched
logger.ts:39 [py-script] py-mount: found 0 elements
logger.ts:39 [py-terminal] Registering stdio listener
logger.ts:39 [pyscript/main] Executing <py-script> tags...
logger.ts:39 [pyscript/main] Initializing web components...
logger.ts:39 [pyscript/main] Startup complete
logger.ts:39 [py-splashscreen] Closing
logger.ts:39 [pyscript/main] PyScript page fully initialized
stdio.ts:37 1
stdio.ts:37 2
stdio.ts:37 3
stdio.ts:37 4
stdio.ts:37 5
stdio.ts:37 6
stdio.ts:37 7
stdio.ts:37 8
stdio.ts:37 9

Additional Context

image

@radiantone radiantone added needs-triage Issue needs triage type: bug Something isn't working labels Feb 4, 2023
@radiantone
Copy link
Author

radiantone commented Feb 4, 2023

The output div is empty
<div class="py-repl-output" id="my-repl-1-1"></div>

@chenchen100
Copy link
Contributor

delete this code in 'repl2.html':
<div style="margin-right: 3rem;">
<py-repl id="my-repl" auto-generate="true"> </py-repl>
<div id="output" class="p-4"></div>
</div>
to:
<div>
<py-repl id="my-repl" auto-generate="true"> </py-repl>
<div id="output" class="p-4"></div>
</div>
in line 40;
this is a bug I think;

@radiantone
Copy link
Author

radiantone commented Feb 5, 2023

Hi. Thanks for reply. I replaced the html I had before with what you wrote

<div>
  <py-repl id="my-repl" auto-generate="true"> </py-repl>
  <div id="output" class="p-4"></div>
</div>

But it didn't fix the problem. Here is what I had before

      <py-repl
        id="my-repl"
        auto-generate="true"
        style="width:95%"
      />

This is embedded in a Vue app by the way. But it worked fine in alpha release.

@chenchen100
Copy link
Contributor

image
Maybe it's not the style problem. I succeeded this morning, but I tried again at 11:00, and it was not successful, whether it was the local deployment or the network(pyolide);
It is strange that it is working again at two o'clock;
I don't know whether it's the network or the bug

@FabioRosado
Copy link
Contributor

FabioRosado commented Feb 5, 2023

Hello @radiantone thank you for raising this issue with us. Since the alpha version, printing things will appear in a py-terminal by default if you don't have a <py-terminal> tag, pyscript should add one. Are you simply adding a py-repl tag in your HTML file?

I've tried to run a for loop like you have on https://pyscript.net/examples/repl2.html and the numbers are shown in py-terminal.

Just wanted to double check, are you using the CSS file from pyscript?
Since you are using Vue, I wonder if either the py-terminal is hidden or if Vue didn't create the file yet. I've started working on a Vue starter and will give it a try 😄

-- UPDATE --

Oh I think I know what's happening, the py-terminal creates a pre element inside the document which means that it will be rendered under the Vue app since the vue app is rendered inside #root. Testing this locally, I see the numbers in a weird place:

Screenshot 2023-02-05 at 12 25 52

@radiantone
Copy link
Author

Let me check on the css again.

@radiantone
Copy link
Author

Yeah, I pull the css in, but because the css in alpha was modifying some other classes outside of py-repl and distorting my app, I had to import it from my Vue component to make it work, but in latest, it now overrides other classes again.

@import "../css/pyscript.css";

I can try removing this and let pyscript.js import the css?

@radiantone
Copy link
Author

image

@FabioRosado
Copy link
Contributor

Do you see the numbers anywhere on the page?
Do you have the code live somewhere so I could pull it and check?

@radiantone
Copy link
Author

Only in the console. No where in the page

@marimeireles
Copy link
Member

Hello, seems like you're using the old API (print)
If you want things to show in the screen you should use display.
old code: print('abc')
new equivalent code: display('abc')

@radiantone
Copy link
Author

Hello, seems like you're using the old API (print) If you want things to show in the screen you should use display. old code: print('abc') new equivalent code: display('abc')

I should hope a basic python print command still works as it should. Otherwise, that's a deal breaker.
But I wrote my own REPL terminal going straight to pyodide and it was pretty easy.

@JeffersGlass
Copy link
Member

I should hope a basic python print command still works as it should. Otherwise, that's a deal breaker.

If you have the bandwidth - I'd be curious if the branch from this PR works in the way you want it to - it restores REPL's prints to stdout to immediately underneath the REPL by default, in a 'notebook-like' fashion. If you don't have a workflow set up to build PyScript from that branch, let me know and I can build a static copy you can like to for testing.

(This may be orthogonal to the issue - per Fabio's comments, this may be a conflict between PyScript's rendering and Vue, which is a little outside my wheelhouse.)

@JeffersGlass JeffersGlass added the classic Issues only applicable to PyScript versions 2023.05.1 and earlier ("PyScript Classic") label Sep 15, 2023
@WebReflection
Copy link
Contributor

our current py-terminal or py-editor is different and it should just work. I think we can close this now but if that's not the case, feel free to re-open the issue or file a new one, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
classic Issues only applicable to PyScript versions 2023.05.1 and earlier ("PyScript Classic") needs-triage Issue needs triage type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants