textual
textual copied to clipboard
ModuleNotFoundError: No module named 'click'
Hey, just tried installing Textual v0.2.0 :slightly_smiling_face: But getting a ModuleNotFoundError:
% pipx install textual
installed package textual 0.2.0, installed using Python 3.10.6
These apps are now globally available
- textual
done! ✨ 🌟 ✨
% textual
Traceback (most recent call last):
File "/home/pawamoy/.local/bin/textual", line 5, in <module>
from textual.cli.cli import run
File "/home/pawamoy/.local/pipx/venvs/textual/lib/python3.10/site-packages/textual/cli/cli.py", line 4, in <module>
import click
ModuleNotFoundError: No module named 'click'
This actually makes sense and is explained just a few paragraph later in the docs: https://textual.textualize.io/getting_started/#textual-cli
But since a CLI is installed when installing textual
only, maybe we could somehow catch this error and print a nice message like "You need to install textual[dev] to run the CLI"?
If that's too much work for very few benefits, then at least we have this issue in the tracker and you can close it :smile:
Nothing official, but the textual
application probably requires that you pip install "textual[dev]"
to work properly.
I was able to replicate exactly what you did, got the same message, but when installing with the [dev] tag it worked just fine (I had to enclose the package name in the double quote characters because I am on OSX, you may or may not need to do that).
End users of your application should never need to run textual, but perhaps some nice message rather than an error would be helpful
I think what we need to do is move the textual commands to a library of its own, and make it a dependancy.
That way you won't have have a textual
on your path if you don't install the dev tools.
Hi, actually textual/cli/cli.py
does import click
, which makes the click package mandatory, even not in dev mode.
I suggest making the click package not optional anymore on the pyproject.toml
to fix the issue in the meanwhile.
Do you want me to create a pull request?
I'm always in favor of reducing dependencies, so I disagree. If there's a way to have a clean opt-in, I'm for it. I'd very much dislike having click installed just to use the textual library.
I do agree with that principle, as soon as the software works. But Textual is broken right now, because of a missing dependency; look at the experience of textual right now :
$ pipx run textual
Traceback (most recent call last):
File "/home/tim/.local/pipx/.cache/79024a2e79a5ffd/bin/textual", line 5, in <module>
from textual.cli.cli import run
File "/home/tim/.local/pipx/.cache/79024a2e79a5ffd/lib/python3.10/site-packages/textual/cli/cli.py", line 4, in <module>
import click
ModuleNotFoundError: No module named 'click'
Do you really think that not fixing it is better than getting the software work at first?
I would not say it's broken as this is expected and documented, but yeah the experience can be better, and @davep opened a PR that does just that in a few lines of code without adding the dependency :rocket:
A crash at first launch is never expected :smile: but now I get your point since I understand their are three ways of using textual:
- developing textual apps
- running textual apps
- using the CLI
Unfortunately, the documentation says as a start:
Installation You can install Textual via PyPI. If you plan on developing Textual apps, then you should install textual[dev]. The [dev] part installs a few extra dependencies for development.
pip install "textual[dev]"
If you only plan on running Textual apps, then you can drop the [dev] part:
pip install textual
that is: "no need to develop apps? just run pip install textual
" which is slightly wrong in this case.
How about either:
- including a documentation change in the PR
- adding a .[cli] target to the package dependencies?
We've added a patch with a more friendly message. But the goal is to not install textual
at all unless you request the dev dependancies. Give us a little time to implement that.