atom-beautify does not find autopep8 when installed in virtual environment (beautifying Python)

Created on 5 May 2015  路  6Comments  路  Source: Glavin001/atom-beautify

I commented on another issue autopep8 Fails when beautifying Python. The symptom is the same, but the error is different, so I opened a new issue.

Thank you in advance!

Error: spawn autopep8 ENOENT
  at exports._errnoException (util.js:734:11)
  at Process.ChildProcess._handle.onexit (child_process.js:1035:32)
  at child_process.js:1127:20
  at process._tickCallback (node.js:357:13)

And the debugging output:

Atom Beautify - Debugging information

The following debugging information was generated by Atom Beautify on Tue May 05 2015 13:32:18 GMT-0500 (CDT).


Platform: darwin

Versions

Atom Version: 0.196.0

Atom Beautify Version: 0.26.5

Original file to be beautified

Original File Path: /Users/fake_user/dev/remsci/dummy_file.py

Original File Grammar: Python

Original File Contents:


from unittest import TestCase


class Bar(TestCase):

    def fakefunction(param, second_param):
        pass

    def test_indentation(self):
        foo = self.fake_function(param='hello',
                                 second_param='world',
                                 )
        bar = 'after_continuing typing'
        return foo, bar

Beautification options

Editor Options:
Options from Atom Editor settings

{
    "indent_size": 4,
    "indent_char": " ",
    "indent_with_tabs": false
}

Config Options:
Options from Atom Beautify package settings

{
    "python": {
        "autopep8_path": "/Users/fake_user/venv/default/bin/autopep8",
        "max_line_length": 79,
        "indent_size": 4,
        "ignore": [
            "E24"
        ]
    },
    "cs": {
        "configPath": ""
    },
    "c": {
        "configPath": ""
    },
    "cpp": {
        "configPath": ""
    },
    "css": {
        "indent_size": 4,
        "indent_char": " ",
        "selector_separator_newline": false,
        "newline_between_rules": false,
        "preserve_newlines": false
    },
    "d": {
        "configPath": ""
    },
    "html": {
        "indent_inner_html": false,
        "indent_size": 4,
        "indent_char": " ",
        "brace_style": "collapse",
        "indent_scripts": "normal",
        "wrap_line_length": 250,
        "wrap_attributes": "auto",
        "wrap_attributes_indent_size": 4,
        "preserve_newlines": true,
        "max_preserve_newlines": 10,
        "unformatted": [
            "a",
            "sub",
            "sup",
            "b",
            "i",
            "u"
        ],
        "end_with_newline": false
    },
    "java": {
        "configPath": ""
    },
    "js": {
        "indent_size": 4,
        "indent_char": " ",
        "indent_level": 0,
        "indent_with_tabs": false,
        "preserve_newlines": true,
        "max_preserve_newlines": 10,
        "space_in_paren": false,
        "jslint_happy": false,
        "space_after_anon_function": false,
        "brace_style": "collapse",
        "break_chained_methods": false,
        "keep_array_indentation": false,
        "keep_function_indentation": false,
        "space_before_conditional": true,
        "eval_code": false,
        "unescape_strings": false,
        "wrap_line_length": 0,
        "end_with_newline": false
    },
    "objectivec": {
        "configPath": ""
    },
    "pawn": {
        "configPath": ""
    },
    "perl": {
        "perltidy_profile": ""
    },
    "php": {
        "fixers": "",
        "level": ""
    },
    "sql": {
        "indent_size": 4,
        "keywords": "upper",
        "identifiers": "lower"
    },
    "vala": {
        "configPath": ""
    }
}

Home Options:
Options from /Users/fake_user/.jsbeautifyrc

{}

EditorConfig Options:
Options from EditorConfig file

{}

Project Options:
Options from .jsbeautifyrc files starting from directory /Users/fake_user/dev/remsci and going up to root

[
    {},
    {},
    {},
    {}
]

Results

Beautified File Contents:

Error: spawn autopep8 ENOENT

Logs:

2015-05-05T18:32:18.183Z - info: [/Users/fake_user/.atom/packages/atom-beautify/src/beautifiers/index.coffee] beautify 
from unittest import TestCase


class Bar(TestCase):

    def fakefunction(param, second_param):
        pass

    def test_indentation(self):
        foo = self.fake_function(param='hello',
                                 second_param='world',
                                 )
        bar = 'after_continuing typing'
        return foo, bar
 [ { indent_size: 4, indent_char: ' ', indent_with_tabs: false },
  { python: 
     { autopep8_path: '/Users/fake_user/venv/default/bin/autopep8',
       max_line_length: 79,
       indent_size: 4,
       ignore: [Object] },
    cs: { configPath: '' },
    c: { configPath: '' },
    cpp: { configPath: '' },
    css: 
     { indent_size: 4,
       indent_char: ' ',
       selector_separator_newline: false,
       newline_between_rules: false,
       preserve_newlines: false },
    d: { configPath: '' },
    html: 
     { indent_inner_html: false,
       indent_size: 4,
       indent_char: ' ',
       brace_style: 'collapse',
       indent_scripts: 'normal',
       wrap_line_length: 250,
       wrap_attributes: 'auto',
       wrap_attributes_indent_size: 4,
       preserve_newlines: true,
       max_preserve_newlines: 10,
       unformatted: [Object],
       end_with_newline: false },
    java: { configPath: '' },
    js: 
     { indent_size: 4,
       indent_char: ' ',
       indent_level: 0,
       indent_with_tabs: false,
       preserve_newlines: true,
       max_preserve_newlines: 10,
       space_in_paren: false,
       jslint_happy: false,
       space_after_anon_function: false,
       brace_style: 'collapse',
       break_chained_methods: false,
       keep_array_indentation: false,
       keep_function_indentation: false,
       space_before_conditional: true,
       eval_code: false,
       unescape_strings: false,
       wrap_line_length: 0,
       end_with_newline: false },
    objectivec: { configPath: '' },
    pawn: { configPath: '' },
    perl: { perltidy_profile: '' },
    php: { fixers: '', level: '' },
    sql: { indent_size: 4, keywords: 'upper', identifiers: 'lower' },
    vala: { configPath: '' } },
  {},
  {},
  {},
  {},
  {},
  {} ] Python /Users/fake_user/dev/remsci/dummy_file.py
2015-05-05T18:32:18.183Z - verbose: [/Users/fake_user/.atom/packages/atom-beautify/src/beautifiers/index.coffee] Python name=Python, namespace=python, grammars=[Python], extensions=[py], type=integer, default=79, description=set maximum allowed line length (Supported by autopep8), title=Python - Max line length, beautifiers=[autopep8], type=integer, default=4, minimum=0, description=Indentation size/length (Supported by autopep8), title=Python - Indent size, beautifiers=[autopep8], type=array, default=[E24], type=string, description=do not fix these errors/warnings (Supported by autopep8), title=Python - Ignore, beautifiers=[autopep8], beautifiers=[autopep8]
2015-05-05T18:32:18.183Z - verbose: [/Users/fake_user/.atom/packages/atom-beautify/src/beautifiers/index.coffee] beautifier autopep8 silly=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, debug=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, verbose=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, info=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, warn=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, error=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, onLogging=function (handler) {
        var subscription;
        subscription = emitter.on('logging', handler);
        return subscription;
      }, silly=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, debug=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, verbose=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, info=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, warn=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, error=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, onLogging=function (handler) {
        var subscription;
        subscription = emitter.on('logging', handler);
        return subscription;
      }, languages=[Python], BASH 3.2 - DISPLAY on /private/tmp/com.apple.launchd.O3V8Ukoszc/org.macosforge.xquartz:0=undefined, Tue May  5 13:32:10 CDT 2015=undefined, =undefined, It is not doing the thing we like to do, but liking the thing we have to do,=undefined, that makes life blessed.=undefined,      -- Goethe=undefined, =undefined, GIT_PS1_SHOWDIRTYSTATE=true, PIP_DOWNLOAD_CACHE=/Users/fake_user/.pip/cache, LESS_TERMCAP_mb=, LESS_TERMCAP_md=, PIP_REQUIRE_VIRTUALENV=true, LESS_TERMCAP_me=, SHELL=/bin/bash, CLICOLOR=1, TMPDIR=/var/folders/dg/_x_l7t090hqc074zc54h418c0000gn/T/, BOWTIE2_INDEXES=/Users/fake_user/work/RemSeq/genome/, Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.Fp2PZdQUak/Render, LESS_TERMCAP_ue=, ATOM_HOME=/Users/fake_user/.atom, USER=fake_user, TIMEFORMAT=, real %3R user %3U    sys %3S pcpu %P=undefined, LD_LIBRARY_PATH=/usr/local/ngs/ngs-sdk/lib64:, COMMAND_MODE=unix2003, SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.y6YCPLAfV3/Listeners, __CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0, PAGER=less, WORKON_HOME=/Users/fake_user/.virtualenvs, LESS_TERMCAP_us=, LSCOLORS=ExFxBxDxCxegedabagacad, PROJECT_HOME=/Users/fake_user/dev, GOOGLE_API_KEY=AIzaSyAQfxPJiounkhOjODEO5ZieffeBv6yft2Q, PATH=/opt/local/bin:/opt/local/sbin:/Users/fake_user/local/bin:/usr/local/bin:/Users/fake_user/Dropbox/bin:/Users/fake_user/local/lib:/Users/fake_user/Dropbox/lib:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin, PWD=/, NGS_BAM_LIBDIR=/usr/local/ngs/ngs-bam/lib64, BOWTIE_INDEXES=/Users/fake_user/work/RemSeq/genome/, NODE_PATH=/Applications/Atom.app/Contents/Resources/app.asar/exports, XPC_FLAGS=0x0, NODE_ENV=production, GIT_PS1_SHOWUNTRACKEDFILES=true, HISTIGNORE=&:bg:fg:ll:h, HISTCONTROL=ignoredups, XPC_SERVICE_NAME=0, LESSCHARSET=latin1, NGS_LIBDIR=/usr/local/ngs/ngs-sdk/lib64, SHLVL=1, HOME=/Users/fake_user, LESS=-i -N -w  -z-4 -g -e -M -X -F -R -P%t?f%f \, :stdin .?pb%pb\%:?lbLine %lb:?bbByte %bb:-...=undefined, PYTHONPATH=/Users/fake_user/dev/scripts:, LOGNAME=fake_user, LESS_TERMCAP_so=, CLASSPATH=/usr/local/ngs/ngs-java/jar/ngs-java.jar:, LESSOPEN=|/usr/bin/lesspipe.sh %s 2>&-, ARCHFLAGS=-arch x86_64, DISPLAY=/private/tmp/com.apple.launchd.O3V8Ukoszc/org.macosforge.xquartz:0, HOSTFILE=/Users/fake_user/.hosts, HISTTIMEFORMAT=[%d/%m %H:%M:%S] , LESS_TERMCAP_se=, _=/usr/bin/env, \e[1;31mHasta la vista, baby\e[m=undefined, _envCacheDate=Tue May 05 2015 13:32:10 GMT-0500 (CDT)
2015-05-05T18:32:18.184Z - debug: [/Users/fake_user/.atom/packages/atom-beautify/src/beautifiers/beautifier.coffee] tempFile input null path=/var/folders/dg/_x_l7t090hqc074zc54h418c0000gn/T/input11545-17456-3jxw1n, fd=39
2015-05-05T18:32:18.185Z - debug: [/Users/fake_user/.atom/packages/atom-beautify/src/beautifiers/beautifier.coffee] spawn autopep8 0=/var/folders/dg/_x_l7t090hqc074zc54h418c0000gn/T/input11545-17456-3jxw1n, 1=--max-line-length, 2=79, 3=--indent-size, 4=4, 5=--ignore, 6=E24
2015-05-05T18:32:18.193Z - debug: [/Users/fake_user/.atom/packages/atom-beautify/src/beautifiers/beautifier.coffee] error Error: spawn autopep8 ENOENT
  at exports._errnoException (util.js:734:11)
  at Process.ChildProcess._handle.onexit (child_process.js:1035:32)
  at child_process.js:1127:20
  at process._tickCallback (node.js:357:13)


question

Most helpful comment

Summary: Officially supported solution for Atom Beautify is to install autopep8 in global Python environment, not in virtual environment.

All 6 comments

This error occurs when autopep8 is not installed. However, Atom Beautify can error like this if it cannot find the installation.

1) Can you confirm you have autopep8 installed?
Run which autopep8 in your Terminal and let me know results

2) What is your PATH environment variable?
Run echo $PATH in your Terminal.
Atom Beautify has detected it as: PATH=/opt/local/bin:/opt/local/sbin:/Users/fake_user/local/bin:/usr/local/bin:/Users/fake_user/Dropbox/bin:/Users/fake_user/local/lib:/Users/fake_user/Dropbox/lib:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin

1) It is installed, though in a virtual environment. The python autopep8 path is correctly set in atom-beautify, which worked before I upgraded.

[09:49:23 31] $ which autopep8
autopep8 is /Users/biiremployee/venv/default/bin/autopep8

I installed autopep8 in my global python installation (which is on my PATH), and this fixes the error. Did atom-beautify stop using the autopep8 path variable in this version?

2) The path as detected by atom-beautify is correct.

Thank you, Glavin001!

I installed autopep8 in my global python installation (which is on my PATH), and this fixes the error.

This makes sense. autopep8 should be in global Python environment.

Did atom-beautify stop using the autopep8 path variable in this version?

Yup, after #282 Atom Beautify attempts to detect the environment variables, such as PATH, and use them. Thus the global Python environment would be used automatically.


Looks like the resolution for this is: install autopep8 in the global Python virtual environment. At the moment, since there is not an option to set a autopep8 path in Atom Beautify, there is no workaround.

  • I think this is OK behavior, is there any reason why installing autopep8 in global virtual environment would be discouraged? If this is OK, then this issue can be closed.
  • I would like to show some helpful messages to help guide users through common problems like this. /cc #311
  • I think this is OK behavior, is there any reason why installing autopep8 in global virtual environment would be discouraged? If this is OK, then this issue can be closed.

This is fine in most cases. I have started using only virtual environments for a number of reasons--mostly because I recently worked on a server where I did not have root access and needed to install a local version of python3 (the sysadmin did not know what he was doing, and the global python did not work).

I wouldn't expect this to be an issue in most cases because I doubt many people use Atom over a server. The bigger issue would be for programmers who don't have admin rights to their workstation, but the best solution there would probably be for them to find another job (IMHO).

tl;dr: Only when there is limited access to the globlal python, so shouldn't be a big deal.

Summary: Officially supported solution for Atom Beautify is to install autopep8 in global Python environment, not in virtual environment.

I have tried to reinstall using pip install autopep8 --force-reinstall. After restarting Atom everything worked.

Was this page helpful?
0 / 5 - 0 ratings