0

I want to install the autopep8 module for python 3 and be able to use it as a command line tool. But installing it this way, as suggested by this answer, using pip3 instead:

pip3 install autopep8

... does not do the trick: when I try to call autopep8 from the command line, I get a "command not found" error and a suggestion to install the python-autopep8 package.

kenny@localhost:~$ pip3 install autopep8
Collecting autopep8
Collecting pep8>=1.5.7 (from autopep8)
  Using cached pep8-1.7.0-py2.py3-none-any.whl
Installing collected packages: pep8, autopep8
Successfully installed autopep8-1.2.2 pep8-1.7.0
kenny@localhost:~$ autopep8
The program 'autopep8' is currently not installed. You can install it by typing:
sudo apt install python-autopep8

But this package is for python 2.7! And I could not find a python3-autopep8 one.

Is there a way to install python 3 modules (using pip3, for example) as executables, in the same manner that you would do, say, npm install -g?

Community
  • 1
  • 1
SylvainB
  • 4,765
  • 2
  • 26
  • 39
  • 1
    you can use the `-m` flag: `python -m autopep8` – DeepSpace May 04 '16 at 14:51
  • are you sure you installed autopep8 without errors and you can `import autopep8` from python3? It's sufficient to `pip3 install autopep8` to get autopep8 binary on my system. Also did you install it system-wide or in your $HOME folder (`--user` option) ? Did you use virtualenv? – Dmitry Ermolov May 04 '16 at 15:02
  • I added my console output when installing and calling autopep8. And yes, when I import it in python 3 I get no errors. – SylvainB May 04 '16 at 16:45
  • Here is my output from installing autopep8 (fresh docker image of ubuntu 16.04) http://pastebin.com/6YKicwnS As you can see `autopep8` is installed to `/usr/local/bin/autopep8`. Maybe you should also try `-vvv` option to make output of pip3 more verbose? – Dmitry Ermolov May 04 '16 at 21:31
  • So apparently it installed the binary in `$HOME/.local/bin`. But I can assure you I did not use `--user` – SylvainB May 09 '16 at 06:48

1 Answers1

0

try this command for installation

pip install --upgrade autopep8

and to use it try

autopep8 --in-place --aggressive --aggressive <filename>

to modify a file in place with aggressive level 2. Remember that autopep8 needs pep8

D.A.G.D
  • 23
  • 1
  • 11
  • output of that second command: `The program 'autopep8' is currently not installed. You can install it by typing: sudo apt install python-autopep8` – SylvainB May 04 '16 at 16:47
  • then type it and tell me... and actually i think that the command is: sudo apt-get install python-autopep8 – D.A.G.D May 04 '16 at 17:04