eran
eran

Reputation: 15136

Automatic python code formatting in sublime

I am trying to find some package that would auto format python code when using sublime.

There is PythonTidy, but when I use PackageController it says install completed but the package is not installed (does not appear in preferences).

I did try following the instructions in: https://github.com/witsch/SublimePythonTidy

and while i "pip installed" the package in python, sublime would not load, throwing:

terminate called after throwing an instance of 'boost::python::error_already_set'
/usr/bin/subl: line 3: 12415 Aborted                 
/usr/lib/sublime-text-2/sublime_text --class=sublime-text-2 "$@"

How would I go about installing this without PackageController, or alternatively, can anyone recommend another package?

Upvotes: 19

Views: 47673

Answers (3)

Aquil Abbas
Aquil Abbas

Reputation: 167

ctrl+shift+P then Package Control: Install Package Look for Python PEP8 Autoformat and install it.

Upvotes: 14

Ofir Farchy
Ofir Farchy

Reputation: 8037

Try doing the following in command line (a bit brute force):

  1. Navigate into the Packages/PythonTidy folder,
    usually ~/.config/sublime-text-2/Packages/PythonTidy
    or ~/.config/sublime-text-2/Packages/SublimePythonTidy
    • If it's non-existent reinstalling using Package Control
  2. Inside there should be another PythonTidy folder (which in your case will be empty).
    Don't get into it, just check it is empty.
  3. Run git clone https://github.com/witsch/PythonTidy.git
  4. Restart sublime and check the console for errors (View -> Show Console)

P.S. If you are unable to start Sublime do a:

sudo pip uninstall PythonTidy

Then retry what I wrote above.

Upvotes: 8

Liam Cain
Liam Cain

Reputation: 13373

Package Control should create an appropriately named folder in Sublime Text's packages folder. You can get there from Preferences > Browse Packages. If the package installed correctly, there should be a folder called PythonTidy. If there's not, you can download the package from github directly and place the folder in this Packages folder.

Upvotes: 1

Related Questions