Johnny
Johnny

Reputation: 869

How to use autopep8 to format code in Spyder / Anaconda

I have been looking for the correct installation instructions to properly install Spyder with Anaconda and then use the autopep8 plugin to format my python code when I am working on Spyder. I was not able to find a single place with the proper procedure. Nevertheless, after spending several hours reading the instructions for Spyder Plug-In installation as well as the GIT autopep8 repository, I was still not certain on the proper procedure. Most of theinstructions pointed to the Spyder plugin directory as the location to drop the autoprep8 code but that did not work either.

So, what is the actual procedure or process to install autoprep8 as a working plugin on Spyder that is part of the Anaconda3 platform?

Upvotes: 0

Views: 3440

Answers (1)

Johnny
Johnny

Reputation: 869

This was a complicated and difficult process to decipher. Several recommendations and observations were found on Google Search with no level of success. I was getting discouraged and almost disappointed that I could not find the answer.

I kept searching and found a clue at the Anaconda Site where I read that Anaconda site-packages folder is the place to drop the files. So, I wanted to share my findings so other programmers can quickly install the autopep8 plugin and get on to the fun part of coding their python projects.

When you are ready to install your Anaconda Programming environment, head on to the Anaconda Web Site and make sure you look for and select the 64 bit version for your OS version. You will find the 32 bit and 64 bit versions under the Download button.
Then install Anaconda and Select to install it for All Users (important tidbit). The remaining default installation is fine. It will take a few minutes to install everything, so go get your beverage of choice and wait for it to complete. Once it is done, head on to the autopep8 GIT repository and download the master files. There are several instructions on this step and multiple repositories, including a pip install version; none of them worked for me, until I found the version from the REPO link that I provided...

From the GIT repo link, select to download the Zipped master package. Unzip the package and navigate to to the directory where you'll find the spyder_autopep8 sub folder.

Open a new Windows Folder and manually type in the following director: C:\Users\All Users\Anaconda3\Lib\ Scroll down the list until you find the site-packages folder. leave it there...

Now, return to the autopep8 folder and Right-Click / copy the spyder_autopep8 directory. Return to the Anaconda3\lib folder area; Right-Click on the site-packages folder / Paste to drop the spyder_autopep8 folder into it. It should only take a second to do this. Double-click on the site-packages folder and confirm that the spyder_autopep8 folder exist on the list of folders. You should see it among the spyder folder group, for there are at least seven folders that starts with spyder_xxxx, and one spyder main folder.

Once you confirm that the folder exists, close the windows Explorer windows and launch Anaconda3. Spyder should be on the list; launch it. Verify that the autopep8 link exists under the Source menu link of Spyder. It should be listed as: Run autopep8 code autoformating

I hope this post will help to reduce wasted time and effort in locating the proper installation of autopep8 on Spyder.

Upvotes: 2

Related Questions