python change configuration_eclipse python configuration

Launch Eclipse

Launch Eclipse. A screen like this should appear, where you can

choose which workspace to open. (If not, go

to File → Switch WorkSpace →

Other )

The Launcher may not have this folder exactly but you can browse

to it or type a similar name to create one (replacing the first xxx

with your name and the second with the number of your course).

Select "Use this as the default and do not ask again. 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.

You should now see Eclipse's Welcome screen:

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

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

Download PyDev from within Eclipse

Go to

"Help > Install New Software..."

Select "Add".

Enter "http://pydev.org/updates" under Location and click

OK.

Back in the "Available Software" window, select the "PyDev for

Eclipse" option. Do not select the "PyDev Mylyn Integration"

flag.

Click

"Next", verify that PyDev is selected in the next window then

select "Next" again.

Select

"I accept the terms of the license agreement" then select "Finish".

The installer will begin to download the plug-in. A window may

appear asking you whether you want to install the plug-in. Select

Install All.

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 and the instillation process will

continue.

When

the installation is complete, you will be asked if you want to

restart Eclipse. Select Yes.

Configure PyDev

Python

must be installed to configure Pydev.

Go to "Window> Preferences". In the Preferences

window, expand "Pydev" and select "Interpreter-Python".

Click "New..." and type Python31 for the Interpreter name. For

the Interpreter executable, browse to your copy of Python

(C:\Program Files\Python31\python.exe), and press Open.

Select ok then the "Selection Needed" Window

will appear.

Select

all but the PySrc and python31.zip and select OK as many times as

necessary to exit the preferences. The default selection should be

fine.

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.

Writing Your First Python Program

Switch to the Python perspective

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

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> New" menu you will see that there are

different options with the different perspective.

Pydev Perspective

Java Perspective

As you can see, perspectives greatly affect the look of the

Eclipse program.

Create a new project

Go to

"File > New > Pydev Project" to start

a wizard.

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.

If you look at the upper left corner of the workspace (in

the Package

Explorerview), you should now see your newly

created project with a "src" folder inside.

Create a new module

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.

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.

The file should be opened in the open space in the center of the

workspace-the Editorview.

(If not, right click on the greeting.py icon and select Open.) You

will see a tab with the name of your file.

Write and run the program

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.

Right click on the file and select Save (or press Ctrl+S) to

save the file.

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

F11.)

Look at the bottom of your screen at

the Consoleview and you

will see the message you told the computer to print.

Congratulations! You have written your first program with

Python.

Configure PyDev for Productivity

Add line numbers

Add

line numbers by right-clicking in the margin at the left side of

the code view and click on Show Line

Numbers.

Change the comment color to one you can read more easily

Go to

Window → Preferences. Open Pydev and select Editors. In the

Appearance Color Options dropdown menu, select Comments. Then

change it to a brighter color (perhaps lavender?).

Turn on Task view to show TODO: items and add a

CONSIDER: tag

Go to

Window → Show View → Tasks.

Window

→ Preferences → Pydev → Task Tags, and add CONSIDER: to the end of

the list.

To get

the task tags to show, run the program once, or select Project →

Clean

One left-over oddity from the days of the MS-DOS operating

system, is that Windows uses a different convention to indicate the

end of lines of input. Unix, Linux, and Mac OS X use a single byte

(with value 13) to indicate the end of a line. Windows uses two

bytes (10 and 13). Somehow the combination of Eclipse, PyDev,

Windows, and Python causes problems for programs that required

console input. Here are two options for avoiding that problem:

Recommended: Add a small patch file to your

Python package (We think this is only needed with

pre-3.4 versions of Eclipse)

Place this win_in.py file

in the same folder where you put graphics.py (probably something

like c:\Program Files\Python25\Lib\site-packages).

At the beginning of your program

file, add from win_in import *

Instead of the input() function, use

win_input()

Instead of the raw_input() function,

use win_raw_input()

You can use the Console in Eclipse like the interactive shell in

IDLE if you configure it correctly. This is

only recommended for advanced Python users.

If that’s you, then follow the directionshere.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值