注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

姑射道人的博客

博客新地址:nixuchen.com

 
 
 

日志

 
 

How to Configure Eclipse for Python  

2014-03-31 15:38:28|  分类: python |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
  1. Launch Eclipse
    1. Launch Eclipse. A screen like this should appear, where you can choose which workspace to open. (If not, go to File → Switch Workspace → Other )

    2.         Screenshots read 'Python 3.1', which is the old version. You will be installing Python 3.2.
    3. How to Configure Eclipse for Python - 姑射道人 - 姑射道人的博客
    4. Browse the csse120 folder which you created when installing Eclipse. Select "Use this as the default and do not ask again".

      1. If you do, Eclipse will automatically use this workspace next time you open Eclipse. If you want to change the workspace later you can always go to File → Switch Workspace... to be sent back to the Workspace Launcher window.

    5. You should now see Eclipse's Welcome screen:

      How to Configure Eclipse for Python - 姑射道人 - 姑射道人的博客

      Click on the arrow on the right to go to the workbench.

      How to Configure Eclipse for Python - 姑射道人 - 姑射道人的博客

      This is where you'll do most of your work in Eclipse.

  2. Download PyDev from within Eclipse
    1. Go to Help → Install New Software
    2.   
    3. Enter http://pydev.org/updates in the Work with:  field.

    4. After several seconds, two options should appear. Select the PyDev for Eclipse option. Do not select the "PyDev Mylyn Integration" flag.

    5.  
    6. Click "Next" and "OK" to continue installing PyDev.
    7. Select "I accept the terms of the license agreement", then click "Finish". The installer will begin to download the plug-in.
    8. Note: When you see the Selection Needed dialog box, you must manually check the box before pressing okay. If you do not, it appears that the installation is continuing, but it is not. You must uninstall PyDev, then reinstall.
    9. A security warning may appear asking whether you trust the software being installed- click "ok", then ensure the correct items are selected and click yes. The instillation process will continue.
    10. When the installation is complete, you will be asked if you want to restart Eclipse. Select "Yes". You may see a Subclipse Usage  dialog, just uncheck the box and continue.
  3. Configure PyDev
    1. Python must be installed to configure PyDev.
    2. Go to Window → Preferences. In the Preferences window, expand PyDev and select Interpreter-Python.

      How to Configure Eclipse for Python - 姑射道人 - 姑射道人的博客
    3. Click "New..." and type Python32 for the Interpreter name. For the Interpreter executable, browse to your copy of Python (C:\Program Files\Python32\python.exe), and press Open.

      How to Configure Eclipse for Python - 姑射道人 - 姑射道人的博客

      Click "OK" and the  Selection Needed Window will appear.

      How to Configure Eclipse for Python - 姑射道人 - 姑射道人的博客
    4. Select all but the PySrc and python32.zip and click OK as many times as necessary to exit the preferences. The default selection should be fine.
    5. The Interpreter is now set up so that the code you write can be interpreted for the computer to run. You are now ready to start running code.

Installing Eclipse Preferences for Python

  1. Download the Eclipse Preferences
    1. Unzip this Preferences for csse120 file, placing its sole unzipped file (EclipsePreference-2011-06.epf)  in any convenient location (your desktop, My Documents folder, etc).

  2. Import the Preferences
    1. Launch Eclipse.

      1. If Eclipse offers to Select a Workspace, browse to C:\EclipseWorkspace\csse120.

      2. If the csse 120 workspace does not appear automatically, choose File → Switch Workspace → Other, and click Next.

    2. Now you are ready to set the preferences for the workspace:

      1. Choose File → Import

      2. In the Import dialog box, select General → Preferences and click Next.

      3. When the Import Preferences dialog opens, select Browse and find the EclipsePreferences-2011-06.epf file that you unzipped and saved above.

      4. Back in the Import Preferences dialog, check Import All, then select Finish.

      5. As before, if the Subclipse Usage dialog makes an appearance, uncheck the box and continue.

      6. Confirm that the installation did not leave behind unintended files by checking if there is:

        1. random .eclipse folder anywhere, possibly in the folder immediately above My Documents.

        2. Any extra users (for example, the installer), in C:\Users

        3. Extra Eclipse workspaces anywhere except for the folders inside C:\EclipseWorkspaces.

Writing Your First Python Program

  1. Switch to the Python perspective
    1. Go to Window → Open Perspective → Other and choose PyDev, then click OK. If you look at the upper right corner you will see that the perspective has changed from "Java" to "PyDev".

      How to Configure Eclipse for Python - 姑射道人 - 姑射道人的博客
    2. Perspectives are designed to have the most useful tools within reach for whatever task you are doing (for example writing Java code or writing Python code). If you look in the File→ Newmenu you will see that there are different options with the different perspective.

      PyDev Perspective 
      Java Perspective 
      How to Configure Eclipse for Python - 姑射道人 - 姑射道人的博客How to Configure Eclipse for Python - 姑射道人 - 姑射道人的博客

      As you can see, perspectives greatly affect the look of the Eclipse program.

  2. Create a new project
    1. Go to File → New → PyDev Project to start a wizard.
    2. In the next window that appears, enter the name of your project and select "python"  and 3.0"; as the type. Make sure "create default 'src' folder and add it to the pythonpath?" is selected. Click Finish.

      How to Configure Eclipse for Python - 姑射道人 - 姑射道人的博客
    3. If you look at the upper left corner of the workspace (in the Package Explorer view), you should now see your newly created project with a "src" folder inside.

      How to Configure Eclipse for Python - 姑射道人 - 姑射道人的博客
  3. Create a new module
    1. Select the project you just created and go to File → New → PyDev Module. This will launch a new PyDev Module Wizard where you should enter a name for your module and make sure it is in the right location. Leave the Package field blank and select Finish.

      How to Configure Eclipse for Python - 姑射道人 - 姑射道人的博客
    2. Look in the Package Explorer view and you will see an icon of your new file inside the src folder, which Eclipse created when you made the new project before.

      How to Configure Eclipse for Python - 姑射道人 - 姑射道人的博客

      The file should be opened in the open space in the center of the workspace-the Editor view. (If not, right click on the greeting.py icon and select Open.) You will see a tab with the name of your file.

      How to Configure Eclipse for Python - 姑射道人 - 姑射道人的博客
  4. Write and run the program
    1. Here's a program to greet the world. Simply type print('Hello, World!') into the file. You may remove the default doc comment or leave it there; Python ignores it.

      How to Configure Eclipse for Python - 姑射道人 - 姑射道人的博客
    2. Right click on the file and select Save (or press Ctrl+S) to save the file.

    3. Finally, choose the greeting.py icon, and go to Run → Run As → Python Run to run your program.

      (A quicker alternative is to right-click on the greeting.py icon, and select Run As → Python Run, or press Ctrl+F11.)

      How to Configure Eclipse for Python - 姑射道人 - 姑射道人的博客
    4. Look at the bottom of your screen at the Console view and you will see the message you told the computer to print.

      How to Configure Eclipse for Python - 姑射道人 - 姑射道人的博客

      Congratulations! You have written your first program with Python.

Configure PyDev for Productivity

  1. Add line numbers
    1. Add line numbers by right-clicking in the margin at the left side of the code view and click on Show Line Numbers
  2. Change the comment color to one you can read more easily
    1. Go to Window → Preferences. Open PyDev and select Editors (actually click on 'Editors', don't just expand it). In the Appearance Color Options dropdown menu, select Comments. Then change it to a brighter color (perhaps fuchsia?).

  3. Turn on Task view  to show TODO: items and add a CONSIDER: tag
    1. Go to Window → Show View → Tasks.
    2. Window → Preferences → PyDev → Task Tags, and add CONSIDER: to the end of the list.
    3. To get the task tags to show, run the program once, or select Project → Clean
  评论这张
 
阅读(689)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017