question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provision for user to troubleshoot `Command not found.` error

See original GitHub issue

Currently, if nbqa and the QA tool to run are installed in different python environments, we would get ValueError: Command black not found. Please make sure you have it installed before running nbqa on it.

This feature adds a provision in nbqa to dump the path of the tool that will be run by nbqa using a command which or a flag --which. This can be print user friendly message if the tool cannot be found by nbqa.

It could be something like

  • nbqa which black - This will introduce a new command.

This would make the user to better troubleshoot this issue and we can document how to handle this scenario in nbqa’s documentation, thus making the user solve such issues on their own.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
girip11commented, Oct 16, 2020

This is the approach I am thinking of

  • Introduce an option nbqa black --find to display black location, version etc as found by nbqa. I can use importutil, imp, pkg_resources modules. This is the success scenario where nbqa is able to find the tool.
black path: <installation path>
black version: <version info>
  • If nbqa can’t find black, then we will display appropriate diagnostic message like what is nbqa installation path, and the used python executable path, then asking users to either install pip(from same location as sys.executable) install black or point to setting up python virtual environment. If case where user can’t resolve this issue, then we can display a message to file bug/issue at nbqa github repo. We can also show a URL to nbqa read the docs in the same message for the user to look at the list of officially tested/supported tools, this way we can keep the nbqa code from displaying officially supported tools.
# Output something like
nbqa cant find the module black.

nbqa install path: /home/user/versions/python-3.8/bin/nbqa
path to python executable: /home/user/versions/python-3.8/bin/python

Please install black using ` /home/user/versions/python-3.8/bin/pip install black` so that nbqa will be able to find black. 
It is recommended  that you  use nbqa and other python QA tools within a virtual environment. [Point to URL about setting up virtual environments which we currently have].

To know the list of officially supported tools by nbqa please visit [nbqa readthedocs url]

If you are still facing issues running nbqa, please file issue at [nbqa github url]
  • When the user runs nbqa black abc.ipynb --nbqa-mutate, if the nbqa raises ValueError("Command not found") in that exception message in addition to what we display today, we will also ask the user to run nbqa black --find to troubleshoot this issue.
Traceback (most recent call last):
File "/home/john/.local/bin/nbqa", line 8, in
sys.exit(main())
File "/home/john/.local/lib/python3.6/site-packages/nbqa/main.py", line 502, in main
for i in cli_args.root_dirs
File "/home/john/.local/lib/python3.6/site-packages/nbqa/main.py", line 502, in
for i in cli_args.root_dirs
File "/home/john/.local/lib/python3.6/site-packages/nbqa/main.py", line 446, in _run_on_one_root_dir
_get_arg(root_dir, tmpdirname, nb_to_py_mapping, project_root),
File "/home/john/.local/lib/python3.6/site-packages/nbqa/main.py", line 360, in _run_command
f"Command {command} not found. "
ValueError: Command black not found. Please make sure you have it installed before running nbqa on it.

Please run `nbqa black --find` to troubleshoot this issue.

This one can be done with minimal changes and it will serve the purpose I think. Please reply if you have any queries.

1reaction
girip11commented, Oct 17, 2020

Thanks both for reviewing. I will start the implementation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix a "Command not found" error in Linux - Red Hat
5 ways to fix "Command not found" errors · 1. Include the path · 2. Add a new path · 3. Copy a...
Read more >
Troubleshoot installation issues for Microsoft Defender for ...
Command -line tool "mdatp" isn't working. If running the command-line tool mdatp gives an error command not found , run the following command:....
Read more >
11 Ways to Fix "The System Cannot Find The Path Specified ...
1. Run Command Prompt as an Administrator ... Windows utilities cannot access all files and folders available on your device. Administrative ...
Read more >
How to fix bash:command not found error in Linux/Unix
To fix this issue permanently so that this issue does not comes up again. You can add the default location of all the...
Read more >
'\r': command not found - .bashrc / .bash_profile - Stack Overflow
Try running the dos2unix command on the file in question. It might help when you see error messages like this: -bash: '\r': command...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found