如何在Spyder/Anaconda中使用autopep8格式化代码 [英] How to use autopep8 to format code in Spyder / Anaconda

查看:1209
本文介绍了如何在Spyder/Anaconda中使用autopep8格式化代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找正确的安装说明,以在Anaconda上正确安装Spyder,然后在使用Spyder时使用autopep8插件格式化python代码.我无法通过正确的程序找到一个地方.但是,在花了几个小时阅读有关Spyder插件安装以及GIT autopep8存储库的说明之后,我仍然不确定正确的过程.大多数说明都将Spyder插件目录指定为放置autoprep8代码的位置,但这也不起作用.

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.

那么,在Anaconda3平台的一部分Spyder上安装autoprep8作为有效插件的实际过程或过程是什么?

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

推荐答案

这是一个复杂而困难的解密过程.在Google搜索上发现了一些建议和意见,但都没有获得成功.我感到沮丧,几乎对我找不到答案感到失望.

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.

我不断搜索并在Anaconda网站上找到了一条线索,在该网站上我读到Anaconda site-packages文件夹是放置文件的地方.因此,我想分享我的发现,以便其他程序员可以快速安装autopep8插件并开始编写其python项目的有趣部分.

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.

当您准备安装Anaconda编程环境时,请访问Anaconda网站,并确保查找并为您的OS版本选择64位版本.您可以在下载按钮下找到32位和64位版本.
然后安装Anaconda,然后选择为所有用户安装"(重要提示).其余的默认安装很好.安装所有组件都需要几分钟,因此,请选择您想要的饮料,然后等待其完成.完成后,转到 autopep8 GIT存储库并下载主文件.关于此步骤有多个说明,并提供了多个存储库,包括pip安装版本.他们都没有为我工作,直到我从我提供的REPO链接中找到了该版本...

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...

从GIT存储库链接中,选择下载Zipped主程序包.解压缩该程序包,然后导航到找到spyder_autopep8子文件夹的目录.

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.

打开一个新的Windows文件夹,然后手动键入以下Director: C:\ Users \ All Users \ Anaconda3 \ Lib \向下滚动列表,直到找到site-packages文件夹.留在那里...

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...

现在,返回到autopep8文件夹,然后右键单击/复制spyder_autopep8目录.返回到Anaconda3 \ lib文件夹区域;右键单击site-packages文件夹/Paste,将spyder_autopep8文件夹放入其中.只需一秒钟即可完成此操作.双击site-packages文件夹,并确认spyder_autopep8文件夹存在于文件夹列表中.您应该在spyder文件夹组中看到它,因为至少有七个以spyder_xxxx开头的文件夹和一个spyder主文件夹.

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.

一旦确认文件夹存在,请关闭Windows资源管理器窗口并启动Anaconda3. Spyder应该在列表中;启动它.验证Spyder的源"菜单链接下是否存在autopep8链接.它应列为:运行autopep8代码自动格式化

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

我希望本文有助于减少在Spyder上正确安装autopep8的时间和精力.

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

这篇关于如何在Spyder/Anaconda中使用autopep8格式化代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆