ftui
ftui copied to clipboard
ImportError: cannot import name 'DEFAULT_COLORS' from 'textual.app'
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.
Exactly the same here.
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?
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: https://github.com/Textualize/textual-plotext/pull/14
This should work for now: https://github.com/freqtrade/ftui/commit/60a8701234b87406d4ad8000bec3c909fb424679
Perfect, thanks guys for the quick update.
It worked.
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.
Awesome, thanks for the info @darrenburns !
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'
@jisnardo Did the Plot class previously have that method? Don't recognise it.
If using the newer plotext version, yes, that function has been renamed: https://github.com/freqtrade/ftui/issues/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?
plotext is 5.3.2 instead of 5.2.8, that causes de issue, just downgrade and works