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

[🐛 BUG] Getting OS Error while using the GUI module. #1779

Open
2 of 4 tasks
RandomArnab opened this issue Sep 11, 2024 · 19 comments
Open
2 of 4 tasks

[🐛 BUG] Getting OS Error while using the GUI module. #1779

RandomArnab opened this issue Sep 11, 2024 · 19 comments
Labels
🖰 GUI Related to GUI 🆘 Help wanted Open to participation from the community 💥Malfunction Addresses an identified problem. 🟨 Priority: Medium Not blocking but should be addressed

Comments

@RandomArnab
Copy link

RandomArnab commented Sep 11, 2024

What went wrong? 🤔

Can't use the GUI module properly from an interactive Python prompt.
image

=>

 File "C:\Users\arnaa\AppData\Local\Programs\Python\Python312\Lib\inspect.py", line 1096, in findsource
    raise OSError('could not get source code')
OSError: could not get source code

Proposed 'solution' (well it's not, really)

Taipy GUI cannot function properly in these conditions because it relies heavily on an actual Python source file, such as one available when running a script or from a Notebook session. Currently, there is no feasible workaround for this limitation.

To address this, we should document the limitation clearly and implement an error message that accurately explains the issue, replacing the existing cryptic exception message.

Acceptance Criteria

  • Ensure the new code is unit tested, and check that the code coverage is at least 90%.
  • Create related issues in taipy-doc for documentation and Release Notes.

Code of Conduct

  • I have checked the existing issues.
  • I am willing to work on this issue (optional)
@RandomArnab RandomArnab added the 💥Malfunction Addresses an identified problem. label Sep 11, 2024
@jrobinAV jrobinAV changed the title [🐛 BUG] <write a small description here> Getting OS Error while using teh GUI module. [🐛 BUG] Getting OS Error while using the GUI module. Sep 12, 2024
@FlorianJacta
Copy link
Member

What Taipy version are you using? Do you use any tools that can conflict with Taipy?

@RandomArnab
Copy link
Author

Taipy version is 3.1.1. I've tried it on multiple environments with python versions of 3.11 and 3.12 but got the same os error while calling the GUI module.

@FlorianJacta
Copy link
Member

FlorianJacta commented Sep 12, 2024

Thank you for the quick answer! Are you coding in a cloud environment?

Can you test:

from taipy.gui import Gui 

Gui(page="# Hello world").run()

@RandomArnab
Copy link
Author

No, I'm running locally.
Still the same error however.
image

@FlorianJacta
Copy link
Member

Did you create a brand new environment for your Taipy installation? Maybe, that could fix this issue.

@FabienLelaquais @FredLL-Avaiga Do you have any idea?

@RandomArnab
Copy link
Author

I tried both ways, on my pre-existing environment with 3.11 python version and on a new environment with 3.12.

@FredLL-Avaiga
Copy link
Member

if think the problem is that you're trying in the console and we need a file...

@FredLL-Avaiga
Copy link
Member

I guess we should give a proper error message

@FlorianJacta
Copy link
Member

FlorianJacta commented Sep 13, 2024

True, I can replicate the issue:

>>> from taipy.gui import Gui
>>> Gui("Hello").run()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\jacta\.conda\envs\4.0\Lib\site-packages\taipy\gui\gui.py", line 2705, in run
    self.__var_dir.set_default(self.__frame)
  File "C:\Users\jacta\.conda\envs\4.0\Lib\site-packages\taipy\gui\utils\_variable_directory.py", line 31, in set_default
    self.add_frame(frame)
  File "C:\Users\jacta\.conda\envs\4.0\Lib\site-packages\taipy\gui\utils\_variable_directory.py", line 38, in add_frame
    imported_var_list = _get_imported_var(frame)
                        ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jacta\.conda\envs\4.0\Lib\site-packages\taipy\gui\utils\get_imported_var.py", line 21, in _get_imported_var
    st = ast.parse(inspect.getsource(frame))
                   ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jacta\.conda\envs\4.0\Lib\inspect.py", line 1279, in getsource
    lines, lnum = getsourcelines(object)
                  ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jacta\.conda\envs\4.0\Lib\inspect.py", line 1261, in getsourcelines
    lines, lnum = findsource(object)
                  ^^^^^^^^^^^^^^^^^^
  File "C:\Users\jacta\.conda\envs\4.0\Lib\inspect.py", line 1090, in findsource
    raise OSError('could not get source code')
OSError: could not get source code

You should use Python files to run a Taipy application.

@jrobinAV jrobinAV added 🖰 GUI Related to GUI 🆘 Help wanted Open to participation from the community 🟨 Priority: Medium Not blocking but should be addressed labels Sep 13, 2024
@jrobinAV jrobinAV added hacktoberfest hacktoberfest issues hacktoberfest - 200💎💎 Issues rewarded by 200 points labels Sep 25, 2024
@Paulie-Aditya
Copy link

using python files should solve the issue. As far as I understood the issue is occurring due to the code being run on a python console

@SGCODEX
Copy link
Contributor

SGCODEX commented Sep 30, 2024

@jrobinAV @Dr-Irv
Hi, please assign me this issue under Devfest ai and Hacktoberfest

@FlorianJacta FlorianJacta assigned SGCODEX and unassigned SGCODEX Oct 1, 2024
@FlorianJacta
Copy link
Member

It seems that you are already assigned to another issue @SGCODEX

@aniketh-varma
Copy link

Hi @FlorianJacta, I can work on this issue. It would be great if you could explain the steps required to solve the issue/preferred solution since this will be my first PR for this repo.

@jrobinAV
Copy link
Member

jrobinAV commented Oct 1, 2024

@aniketh-varma Let me assign the issue to you. Thanks for your help.

For your questions, I let @FabienLelaquais @FredLL-Avaiga @dinhlongviolin1 @namnguyen20999 answer. They are the right persons.

@aniketh-varma
Copy link

Hey @FabienLelaquais @FredLL-Avaiga @dinhlongviolin1 @namnguyen20999 , can you please help me with a preferred solution for the issue.

@FabienLelaquais
Copy link
Member

Hi @RandomArnab, @aniketh-varma, and @SGCODEX.
Thank you for your interest in the topic.

Unfortunately (or fortunately), @Paulie-Aditya is right (and @FlorianJacta confirms it): Taipy GUI cannot run straight from the console because it needs runtime information (like locating callback functions or tricky bindings) that are available only when the script is an actual file.
Interactive Python interpreters do not provide such a facility, and we fail to do anything.

As @FredLL-Avaiga points out, the least Taipy could do is document this limitation and issue a more informative error message.
We will, in the short term.

I recommend we keep this issue open, and I add a note on this discovery in the description.

Thanks again,

Copy link

quest-bot bot commented Oct 7, 2024

New Quest! image New Quest!

A new Quest has been launched in @Avaiga’s repo.
Merge a PR that solves this issue to loot the Quest and earn your reward.


Some loot has been stashed in this issue to reward the solver!

🗡 Comment @quest-bot embark to check-in for this Quest and start solving the issue. Other solvers will be notified!

⚔️ When you submit a PR, comment @quest-bot loot #1779 to link your PR to this Quest.

Questions? Check out the docs.

@quest-bot quest-bot bot added the ⚔️ Quest Tracks quest-bot quests label Oct 7, 2024
Copy link
Contributor

This issue has been labelled as "🥶Waiting for contributor" because it has been inactive for more than 14 days. If you would like to continue working on this issue, please add another comment or create a PR that links to this issue. If a PR has already been created which refers to this issue, then you should explicitly mention this issue in the relevant PR. Otherwise, you will be unassigned in 14 days. For more information please refer to the contributing guidelines.

@github-actions github-actions bot added the 🥶Waiting for contributor Issues or PRs waiting for a long time label Oct 22, 2024
@github-actions github-actions bot removed the 🥶Waiting for contributor Issues or PRs waiting for a long time label Nov 6, 2024
Copy link
Contributor

github-actions bot commented Nov 6, 2024

This issue has been unassigned automatically because it has been marked as "🥶Waiting for contributor" for more than 14 days with no activity.

@jrobinAV jrobinAV removed hacktoberfest hacktoberfest issues hacktoberfest - 200💎💎 Issues rewarded by 200 points ⚔️ Quest Tracks quest-bot quests labels Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🖰 GUI Related to GUI 🆘 Help wanted Open to participation from the community 💥Malfunction Addresses an identified problem. 🟨 Priority: Medium Not blocking but should be addressed
Projects
None yet
Development

No branches or pull requests

8 participants