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

ImportError: cannot import name 'DEFAULT_COLORS' from 'textual.app' #11

Open
jisnardo opened this issue Nov 26, 2024 · 11 comments
Open

Comments

@jisnardo
Copy link

Hi, after setup, not able to start.

(.venv) test@pc:~/freqtrade/2024/ftui-0.1.5$ ftui -y config.yaml 
Traceback (most recent call last):
  File "/freqtrade/2024/ftui-0.1.5/.venv/bin/ftui", line 5, in <module>
    from ftui.ftui import main
  File "/freqtrade/2024/ftui-0.1.5/ftui/ftui.py", line 33, in <module>
    from ftui.screens.dashboard_screen import DashboardScreen
  File "/freqtrade/2024/ftui-0.1.5/ftui/screens/dashboard_screen.py", line 20, in <module>
    from textual_plotext import PlotextPlot
  File "/freqtrade/2024/ftui-0.1.5/.venv/lib/python3.10/site-packages/textual_plotext/__init__.py", line 3, in <module>
    from .plot import Plot, themes
  File "/freqtrade/2024/ftui-0.1.5/.venv/lib/python3.10/site-packages/textual_plotext/plot.py", line 21, in <module>
    from textual.app import DEFAULT_COLORS
ImportError: cannot import name 'DEFAULT_COLORS' from 'textual.app' (/freqtrade/2024/ftui-0.1.5/.venv/lib/python3.10/site-packages/textual/app.py)

Thanks.

@alfirin
Copy link

alfirin commented Nov 26, 2024

Exactly the same here.

@alfirin
Copy link

alfirin commented Nov 26, 2024

Image

@xmatthias
Copy link
Member

that particular import still works with textual==0.85.0 - but fails starting with 0.86.0.

odd that it wasn't mentioned in release notes ... but textual itself seems to be quite in flux - maybe we should hard-pin it to avoid such failures?

@froggleston
Copy link
Collaborator

froggleston commented Nov 27, 2024

This is down to the Textual library changing from the previous theming system to a new one. The plotext library hasn't been updated to reflect this core change, but a PR is open: Textualize/textual-plotext#14

This should work for now: 60a8701

@alfirin
Copy link

alfirin commented Nov 28, 2024

Perfect, thanks guys for the quick update.

It worked.

@darrenburns
Copy link

You should pin Textual, as it's still zerover and so the API is subject to change.

We'll be hitting 1.0.0 soon, and then trying to adhere to SemVer as much as possible.

We've just released a new version of textual-plotext, which hopefully resolves the issues.

@froggleston
Copy link
Collaborator

Awesome, thanks for the info @darrenburns !

@jisnardo
Copy link
Author

Thanks! it works, but now complains about this:

│ /ftui-0.1.5/.venv/lib/python3.10/site-packages/textual/worker.py:368 in _run                                                                       │
│                                                                                                                                                                           │
│   365 │   │   │   self.state = WorkerState.RUNNING                                                                                                                        │
│   366 │   │   │   app.log.worker(self)                                                                                                                                    │
│   367 │   │   │   try:                                                                                                                                                    │
│ ❱ 368 │   │   │   │   self._result = await self.run()                                                                                                                     │
│   369 │   │   │   except asyncio.CancelledError as error:                                                                                                                 │
│   370 │   │   │   │   self.state = WorkerState.CANCELLED                                                                                                                  │
│   371 │   │   │   │   self._error = error                                                                                                                                 │
│                                                                                                                                                                           │
│ ╭────────────────────────────────────────────────────────────── locals ───────────────────────────────────────────────────────────────╮                                   │
│ │           app = FreqText(title='FreqText', classes={'-dark-mode', '-show-clients'}, pseudo_classes={'focus', 'dark'})               │                                   │
│ │         error = AttributeError("'Plot' object has no attribute 'datetimes_to_string'")                                              │                                   │
│ │          self = <Worker                                                                                                             │                                   │
│ │                 │   ERROR                                                                                                           │                                   │
│ │                 │   name='update_cumulative_profit_plot'                                                                            │                                   │
│ │                 │   group='dash_chart_worker'                                                                                       │                                   │
│ │                 │   description="update_cumulative_profit_plot(bot_list=['ftspot01_bot', 'ftspot03_bot'])"                          │                                   │
│ │                 >                                                                                                                   │                                   │
│ │ worker_failed = WorkerFailed('Worker raised exception: AttributeError("\'Plot\' object has no attribute \'datetimes_to_string\'")') │                                   │
│ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯                                   │
│                                                                                                                                                                           │
│ /ftui-0.1.5/.venv/lib/python3.10/site-packages/textual/worker.py:352 in run                                                                        │
│                                                                                                                                                                           │
│   349 │   │   Returns:                                                                                                                                                    │
│   350 │   │   │   Return value of the work.                                                                                                                               │
│   351 │   │   """                                                                                                                                                         │
│ ❱ 352 │   │   return await (                                                                                                                                              │
│   353 │   │   │   self._run_threaded() if self._thread_worker else self._run_async()                                                                                      │
│   354 │   │   )                                                                                                                                                           │
│   355                                                                                                                                                                     │
│                                                                                                                                                                           │
│ ╭───────────────────────────────────────────── locals ──────────────────────────────────────────────╮                                                                     │
│ │ self = <Worker                                                                                    │                                                                     │
│ │        │   ERROR                                                                                  │                                                                     │
│ │        │   name='update_cumulative_profit_plot'                                                   │                                                                     │
│ │        │   group='dash_chart_worker'                                                              │                                                                     │
│ │        │   description="update_cumulative_profit_plot(bot_list=['ftspot01_bot', 'ftspot03_bot'])" │                                                                     │
│ │        >                                                                                          │                                                                     │
│ ╰───────────────────────────────────────────────────────────────────────────────────────────────────╯                                                                     │
│                                                                                                                                                                           │
│ /ftui-0.1.5/.venv/lib/python3.10/site-packages/textual/worker.py:324 in _run_threaded                                                              │
│                                                                                                                                                                           │
│   321 │   │                                                                                                                                                               │
│   322 │   │   loop = asyncio.get_running_loop()                                                                                                                           │
│   323 │   │   assert loop is not None                                                                                                                                     │
│ ❱ 324 │   │   return await loop.run_in_executor(None, runner, self._work)                                                                                                 │
│   325 │                                                                                                                                                                   │
│   326 │   async def _run_async(self) -> ResultType:                                                                                                                       │
│   327 │   │   """Run an async worker.                                                                                                                                     │
│                                                                                                                                                                           │
│ ╭───────────────────────────────────────────── locals ──────────────────────────────────────────────╮                                                                     │
│ │ loop = <_UnixSelectorEventLoop running=True closed=False debug=False>                             │                                                                     │
│ │ self = <Worker                                                                                    │                                                                     │
│ │        │   ERROR                                                                                  │                                                                     │
│ │        │   name='update_cumulative_profit_plot'                                                   │                                                                     │
│ │        │   group='dash_chart_worker'                                                              │                                                                     │
│ │        │   description="update_cumulative_profit_plot(bot_list=['ftspot01_bot', 'ftspot03_bot'])" │                                                                     │
│ │        >                                                                                          │                                                                     │
│ ╰───────────────────────────────────────────────────────────────────────────────────────────────────╯                                                                     │
│                                                                                                                                                                           │
│ /usr/lib/python3.10/concurrent/futures/thread.py:58 in run                                                                                                                │
│                                                                                                                                                                           │
│    55 │   │   │   return                                                                       ╭── locals ───╮                                                            │
│    56 │   │                                                                                    │ self = None │                                                            │
│    57 │   │   try:                                                                             ╰─────────────╯                                                            │
│ ❱  58 │   │   │   result = self.fn(*self.args, **self.kwargs)                                                                                                             │
│    59 │   │   except BaseException as exc:                                                                                                                                │
│    60 │   │   │   self.future.set_exception(exc)                                                                                                                          │
│    61 │   │   │   # Break a reference cycle with the exception 'exc'                                                                                                      │
│                                                                                                                                                                           │
│ /ftui-0.1.5/.venv/lib/python3.10/site-packages/textual/worker.py:307 in run_callable                                                               │
│                                                                                                                                                                           │
│   304 │   │   def run_callable(work: Callable[[], ResultType]) -> ResultType:                                                                                             │
│   305 │   │   │   """Set the active worker, and call the callable."""                                                                                                     │
│   306 │   │   │   active_worker.set(self)                                                                                                                                 │
│ ❱ 307 │   │   │   return work()                                                                                                                                           │
│   308 │   │                                                                                                                                                               │
│   309 │   │   if (                                                                                                                                                        │
│   310 │   │   │   inspect.iscoroutinefunction(self._work)                                                                                                                 │
│                                                                                                                                                                           │
│ ╭────────────────────────────────────────────────────────────────────────────── locals ──────────────────────────────────────────────────────────────────────────────╮    │
│ │ self = <Worker                                                                                                                                                     │    │
│ │        │   ERROR                                                                                                                                                   │    │
│ │        │   name='update_cumulative_profit_plot'                                                                                                                    │    │
│ │        │   group='dash_chart_worker'                                                                                                                               │    │
│ │        │   description="update_cumulative_profit_plot(bot_list=['ftspot01_bot', 'ftspot03_bot'])"                                                                  │    │
│ │        >                                                                                                                                                           │    │
│ │ work = functools.partial(<function DashboardScreen.update_cumulative_profit_plot at 0x7d3ff214c700>, DashboardScreen(), bot_list=['ftspot01_bot', 'ftspot03_bot']) │    │
│ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯    │
│                                                                                                                                                                           │
│ /ftui-0.1.5/ftui/screens/dashboard_screen.py:449 in update_cumulative_profit_plot                                                                  │
│                                                                                                                                                                           │
│   446 │   │   │                                                                                                                                                           │
│   447 │   │   │   all_cum_data.index = all_cum_data.index.tz_localize(None)                                                                                               │
│   448 │   │   │                                                                                                                                                           │
│ ❱ 449 │   │   │   dates = cplt.datetimes_to_string(all_cum_data.index)                                                                                                    │
│   450 │   │   │                                                                                                                                                           │
│   451 │   │   │   cplt.plot(                                                                                                                                              │
│   452 │   │   │   │   dates,                                                                                                                                              │
│ │            cplt = <textual_plotext.plot.Plot object at 0x7d3fee325b10>                                                                                                │ │
│ │            dfmt = 'Y-m-d'                                                                                                                                             │ │
│ │            self = DashboardScreen()
AttributeError: 'Plot' object has no attribute 'datetimes_to_string'

@darrenburns
Copy link

@jisnardo Did the Plot class previously have that method? Don't recognise it.

@froggleston
Copy link
Collaborator

froggleston commented Nov 29, 2024

If using the newer plotext version, yes, that function has been renamed: #9

So we're at a bit of an impasse. I'll need to properly address both issues.

@jisnardo what are your package versions? I've just tried with textual 0.85,0, plotext 5.2.8 and textual-plotext 0.2.1 and it seems to work?

@jisnardo
Copy link
Author

plotext is 5.3.2 instead of 5.2.8, that causes de issue, just downgrade and works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants