이 교본은 파이썬 3에 집중하고 있습니다. This tutorial focuses on Python 3.
Most Linux distribution for e.g Ubuntu 14.04 comes with python 2 and 3 installed, here is the download link. If you are using some other linux distribution see this link for installation instructions. Mac also comes with python 2 and python 3 installed (if not see this link for instructions), but this is not the case with windows.
Note: Throughout this tutorial i will give instructions wherever necessary for Windows and Ubuntu 14.04 only.
Installing Python 3 in Windows
To install python you need to download python binary from https://www.python.org/downloads/, specifically we will be using python 3.4.3 which you can download from here . While installing remember to check “Add Python.exe to path” (see the image below).
Now you have installed python, open command prompt or terminal and type python . Now you are in python shell.
To test everything is working fine type the following command in the python shell.
Expected output:
If you are using Ubuntu 14.04 which already comes with python 2 and python 3, you need to enter python3 instead of just python to enter python 3 shell.
Installing Text Editor
To write python programs you will need a text editor, you can use text editor like notepad. If you want to use full-fledged text editor then use notepad++ or sublime text. Download and install text editor of you choice.
Now you have successfully installed python 3 and text editor and ready to move on to the next chapter, where we will learn different ways of running python programs.
Visit https://www.python.org/downloads/ and download the latest version. The installation is just like any other Windows-based software.
CAUTION | When you are given the option of unchecking any "optional" components, don’t uncheck any. |
5.1.1. DOS Prompt
당신이 Windows 명령 줄 즉, DOS 프롬프트에서 파이썬을 사용할 수 있도록 하려면, 당신은 적절하게 PATH 변수를 설정해야 합니다.
If you want to be able to use Python from the Windows command line i.e. the DOS prompt, then you need to set the PATH variable appropriately.
윈도우 2000, XP, 2003의 경우, 제어판 → 시스템 → 고급 → 환경 변수를 클릭합니다. 시스템 변수 섹션에서라는 PATH라는 이름의 변수를 클릭한 다음, 편집을 선택하고 이미 있는 것의 끝에 ;C: \ Python27을 추가하십시오(이 폴더가 있는지 확인하십시오, 그것은 파이썬의 새 버전 다를 수 있습니다). 물론, 적절한 디렉토리 이름을 사용합니다.
For Windows 2000, XP, 2003 , click on Control Panel → System → Advanced → Environment Variables. Click on the variable named PATH in the System Variables section, then select Edit and add ;C:\Python27
(please verify that this folder exists, it will be different for newer versions of Python) to the end of what is already there. Of course, use the appropriate directory name.
AUTOEXEC.BAT \과 라인 PATH = % 경로 %를 추가; C를 : 이전 버전의 Windows의 경우, 파일 C를 열고 \ Python33하고 시스템을 재시작합니다. 윈도우 NT의 경우, AUTOEXEC.NT 파일을 사용합니다.
For older versions of Windows, open the file C:\AUTOEXEC.BAT
and add the line PATH=%PATH%;C:\Python33
and restart the system. For Windows NT, use the AUTOEXEC.NT file.
Windows Vista의 경우:
For Windows Vista:
Click Start and choose Control Panel
Click System, on the right you’ll see "View basic information about your computer"
On the left is a list of tasks, the last of which is Advanced system settings. Click that.
The Advanced tab of the System Properties dialog box is shown. Click the Environment Variables button on the bottom right.
In the lower box titled System Variables scroll down to Path and click the Edit button.
Change your path as need be.
Restart your system. Vista didn’t pick up the system path environment variable change until I restarted.
For Windows 7 and 8:
마우스 오른쪽 버튼으로 바탕 화면에서 컴퓨터를 클릭하고 속성을 선택하거나 시작을 클릭하고 제어판 → 시스템 및 보안 → 시스템을 선택합니다. 왼쪽에 있는 고급 시스템 설정을 클릭한 다음 고급 탭을 클릭합니다. 환경 변수 및 시스템 변수에서 아래 클릭에서, PATH 변수를 찾아 선택한 다음 편집을 누릅니다.
Right click on Computer from your desktop and select Properties or click Start and choose Control Panel → System and Security → System. Click on Advanced system settings on the left and then click on the Advanced tab. At the bottom click on Environment Variables and under System variables, look for the PATH variable, select and then press Edit.변수 값에서 줄의 끝으로 이동하여 추가; C : \ Python27이 이미 무엇의 끝 (이 폴더가 있는지 확인하십시오, 그것은 파이썬의 새 버전에 대해 서로 다른 것입니다). 물론, 해당 폴더 이름을 사용합니다.
Go to the end of the line under Variable value and append;C:\Python27
(please verify that this folder exists, it will be different for newer versions of Python) to the end of what is already there. Of course, use the appropriate folder name.If the value was
%SystemRoot%\system32;
It will now become%SystemRoot%\system32;C:\Python27
Click OK and you are done. No restart is required, however you may have to close and reopen the command line.
5.1.2. Running Python prompt on Windows
For Windows users, you can run the interpreter in the command line if you have set the PATH
variable appropriately.
To open the terminal in Windows, click the start button and click Run. In the dialog box, type cmd and press enter key.
Then, type python and ensure there are no errors.
5.2. Installation on Mac OS X
For Mac OS X users, Python must be installed already.
To verify, open the terminal by pressing Command+Space keys (to open Spotlight search), type Terminal and press enter key. Now, run python and ensure there are no errors.
5.3. Installation on GNU/Linux
For GNU/Linux users, Python must be installed already.
To verify, open the terminal by opening the Terminal application or by pressing Alt+F2 and entering gnome-terminal. If that doesn’t work, please refer the documentation of your particular GNU/Linux distribution. Now, run python and ensure there are no errors.
You can see the version of Python on the screen by running:
$ python -V Python 2.7.6
NOTE | $ is the prompt of the shell. It will be different for you depending on the settings of the operating system on your computer, hence I will indicate the prompt by just the $ symbol. |
CAUTION | Output may be different on your computer, depending on the version of Python software installed on your computer. |
5.4. Summary
From now on, we will assume that you have Python installed on your system.
Next, we will write our first Python program.
'Python 배우기' 카테고리의 다른 글
PyQt5 Beginner tutorial (0) | 2016.03.04 |
---|---|
First Steps (0) | 2016.01.05 |
Introduction (0) | 2016.01.05 |
Dedication Preface (0) | 2016.01.05 |
Welcome (0) | 2016.01.05 |
댓글