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

Could not find 'black'. The program may not be installed. #2597

Open
5 tasks done
Doekeb opened this issue Nov 17, 2021 · 5 comments · May be fixed by #2622
Open
5 tasks done

Could not find 'black'. The program may not be installed. #2597

Doekeb opened this issue Nov 17, 2021 · 5 comments · May be fixed by #2622

Comments

@Doekeb
Copy link

Doekeb commented Nov 17, 2021

Description

Atom Beautify cannot find Black. Running Atom Beautify on even an empty Python file fails with the following message:

Could not find 'black'. The program may not be installed.

See black installation instructions at https://github.com/Glavin001/atom-beautify#beautifiers or go to https://github.com/ambv/black#installation
You can configure Atom Beautify with the absolute path to 'black' by setting 'Executable - black - Path' in the Atom Beautify package settings.
Your program is properly installed if running 'which black' in your Terminal returns an absolute path to the executable.
Hide Stack Trace
Error: Could not find 'black'. The program may not be installed.
    at Function.Executable.commandNotFoundError (/home/doeke/.atom/packages/atom-beautify/src/beautifiers/executable.coffee:277:10)
    at HybridExecutable.Executable.commandNotFoundError (/home/doeke/.atom/packages/atom-beautify/src/beautifiers/executable.coffee:269:18)
    at /home/doeke/.atom/packages/atom-beautify/src/beautifiers/executable.coffee:115:25
    at tryCatcher (/home/doeke/.atom/packages/atom-beautify/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/doeke/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/home/doeke/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/home/doeke/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/home/doeke/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:725:18)
    at _drainQueueStep (/home/doeke/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/home/doeke/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/home/doeke/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:102:5)
    at Async.drainQueues (/home/doeke/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:15:14)

Steps to Reproduce

  1. Create an empty Python file, e.g. test.py.
  2. Run command Atom Beautify: Beautify Editor
  3. The above error message is returned

Note: I have double-checked that black is installed (in my system python—not a virtual environment). Running which black returns the absolute path. I get the same results as above even if I set the absolute path of the executable in Atom Beautify settings. Additionally, I can successfully run black on a file manually from the command line.

Debug

Here is a link to the debug.md Gist: https://gist.github.com/Doekeb/28a2722ef36c776a733b61d3e5d9f0ba

Checklist

I have:

  • Tried uninstalling and reinstalling Atom Beautify to ensure it installed properly
  • Reloaded (or restarted) Atom to ensure it is not a caching issue
  • Searched through existing Atom Beautify Issues at https://github.com/Glavin001/atom-beautify/issues
    so I know this is not a duplicate issue
  • Filled out the Input, Expected, and Actual sections above or have edited/removed them in a way that fully describes the issue.
  • Generated debugging information by executing Atom Beautify: Help Debug Editor command in Atom and added link for debug.md Gist to this issue
@ErielCruz
Copy link

I am experiencing the same issue and have followed the same troubleshooting steps described by Doekeb without success :/

@ZeePal
Copy link

ZeePal commented Dec 9, 2021

possible insight that might help debugging:

mine was working fine then i did an pip3 install --upgrade black
New version (broken):

❯ black --version
black, 21.12b0 (compiled: no)

I cant remember what version I had before but I rolled back to pip3 install black==21.10b0 and its working again

@ThatXliner
Copy link

Same. Only black==21.10b worked

@claytonjroberts
Copy link

For anyone looking for a quick solution: pip install --upgrade black==21.10b0

@jeanfrancoiscaty
Copy link

Figured out the issue, version number is getting reported differently now.
regex is looking for black, version X.Y.Z but version is now black, X.Y.Z

Cracked open packages/atom-beautify/src/beautifiers/black.coffee and updated the catch:

          try
            text.match(/black, version (\d+\.\d+)/)[1] + "." + text.match(/b(\d+)$/)[1]
          catch
            try
              text.match(/black, version (\d+\.\d+)/)[1] + ".0"
            catch
              text.match(/black, (\d+\.\d+\.\d+)/)[1]

Good enough for me, will look into contributing a proper PR for it when I have the bandwidth.

Doekeb added a commit to Doekeb/atom-beautify that referenced this issue May 27, 2022
na-trium-144 added a commit to na-trium-144/atom-beautify that referenced this issue Sep 28, 2022
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

Successfully merging a pull request may close this issue.

6 participants