Monday, 3 April 2017

[Selenium] 2. install IDE - pyCharm

寫Code就要用IDE,這是我第一次接觸python ,目前就選擇的pyCharm,據說是最好的IDE,目前使用還不錯。 如果你沒有偏好的IDE,那先跟我一起使用pyCharm Community Edition。

pyCharm 有付費版本跟免費版本, 而pyCharm Community Edition 是免費版的。

下載點 : https://www.jetbrains.com/pycharm/download/#section=windows

Double-click pycharm-community-yyyy.m.exe file to launch the installer. You computer verifies it, and then opens the first page of the installation wizard:

雙擊pycharm-community-yyyy.m.exe文件以啟動安裝程序:



Click Next
點擊Next (下一步)

On the second page of the wizard, you have to specify whether you wish a previous installation to be uninstalled, and, moreover, silently:

在第二步,您必須指定是否希望卸載先前的安裝:


Click Next 

點擊Next (下一步)

3. On the Choose Install Location screen, specify the destination directory where the product will be installed. The installation wizard suggests a default location. To choose a custom location, click Browse and select the desired location in your file system. When ready, click Next.

3.在“Choose Install Location (選擇安裝位置)”屏幕上,指定要安裝的目標目錄。建議默認位置。如果要選擇自定義位置,請單擊瀏覽並在文件系統中選擇所需的位置。準備好後,單擊下一步。



4. On the Installation Options screen, specify the following options:

4.在“Installation Options(安裝選項)”上,指定以下要安裝的選項:




  • Create Desktop shortcut: if you select this check box, the shortcut to PyCharm Edu will appear on your Desktop. Thus you will be able to launch PyCharm Edu from your Desktop, by double-clicking this shortcut icon. If you leave this check-box unselected (this is what the installer suggests), then the shortcut on the Desktop will not be created, and you will have to launch the application from the Start menu or from your file system only.
  • 創建桌面快捷方式:如果選中此Checkbox(復選框),PyCharm Edu的快捷方式將顯示在桌面上。因此,您可以通過雙擊此快捷方式圖標從桌面啟動PyCharm Edu。如果您未選擇此復選框(這是安裝程序建議),則桌面上的快捷方式將不會被創建,您將不得不從“開始”菜單或僅從您的文件系統啟動該應用程序。

  • If you are working on Windows XP, you can opt to select the check-box Create Quick Launch shortcut.
  • 如果您使用的是Windows XP,則可以選擇“創建快速啟動”快捷方式。
  • Choose Python version: in this section, you have to specify which Python version will be installed for PyCharm Edu. The installer suggests you to choose between Python 2.7 and Python 3.5 (which is pre-installed). If you are not sure which version suits you better, refer to the comparison of versions.
  • 選擇Python版本:您必須指定為PyCharm Edu安裝哪個Python版本。安裝程序建議您選擇Python 2.7和Python 3.5(預先安裝)。如果您不確定哪個版本適合您,請參閱版本的比較。我的課程請安裝Python 3.x版


5. On this page of the installation wizard, you have to specify in which folder of the Start menu the application shortcuts will appear. If you do not enter the folder name, then your Start menu will contain the folder JetBrains.
此頁面上,您必須指定開始菜單的哪個文件夾將顯示應用程序快捷方式。如果您沒有輸入文件夾名稱,則“開始”菜單將包含JetBrains文件夾。

Click Install.
單擊Install (安裝)。



See how the installation works:

看安裝的進度:



6.When the installation is ready, you see the last page of the wizard:
6.安裝準備就緒後,您將看到最後一頁:


Select the checkbox Run PyCharm Community Edition (if you want to launch the product immediately), and click Finish.
選中運行PyCharm Community Edition(如果要立即啟動產品)複選框,然後單擊Finish完成。


If you have had a previous install of PyCharm you can import your previous settings.

如果您以前安裝了PyCharm,您可以導入以前的設置。

PyCharm gives you the option to use a selection of themes, this is down to personal preference, but for those that are planning long coding sessions, Darcula is always easier on the eyes.

PyCharm可以讓您選擇使用主題,這取決於個人喜好,但對於那些長時間編碼的人來說,Darcula是對眼睛比較好的。


Now PyCharm is installed we’re ready to create our first project

現在,PyCharm已經安裝好,我們可以來創建我們的第一個項目


Change the name in the location textbox to HelloWorld and click "Create"

將位置文本框中的名稱更改為HelloWorld,然後單擊“Create

Now that our project has been created we need a Python file in which we can write code. Select File from the menu then New.

現在我們的項目已經創建,我們需要一個Python文件,我們可以在其中編寫代碼。從菜單中選擇 File (文件) ,然後選擇New...(新建)。


Select Python File from the available options
從選項中選擇Python文件

Finally we need to select a name for our Python file, just use Hello
最後,我們需要為我們的Python文件選擇一個名稱,使用Hello

At last we’re ready to write our first Python program and it’s a very simple one.
最後,我們準備編寫我們的第一個Python程序,這是一個非常簡單的程序。

In the new tab that has been opened type print(“hello world”)
在新的頁面,輸入 print(“hello world”)

You will notice that whilst typing print you will see a pop up displaying information about the method, and PyCharm will automatically add the closing bracket, how thoughtful!

你會注意到在敲打時你會看到一個彈出來顯示關於該方法的信息,PyCharm會自動添加關閉括號,設想非常周到!



Now all that’s left to do is run the program, you can do this by selecting run -> run hello from the menu bar, to pressing shift F10.

現在剩下要做的就是運行程序,你可以通過從菜單欄中選擇run  - > run hello,按shift F10來執行。


Note an output windows has appeared at the bottom of the application containing the below text:

注意,輸出窗口出現在包含以下文本的應用程序底部:路徑會依個人安裝和項目的路徑而不同

C:\Programs\Python36\python.exe C:/Kenneth/Projects/Selenium/HelloWorld/HelloWorld.py

hello world

Process finished with exit code 0

So, what does this mean? Well C:\Programs\Python36\python.exe is the executable of the Python interpreter on your PC.

這是什麼意思? C:\ Programs \ Python36 \ python.exe是您的PC上的Python解釋器的可執行文件。

C:/Users/kenneth/PycharmProjects/HelloWorld/Hello.py is the file we have created that has been executed, note the file name HelloWorld.py inside of the HelloWorld project

C:/Users/kenneth/PycharmProjects/HelloWorld/Hello.py是我們已經執行的文件,請注意HelloWorld項目中的文件名HelloWorld.py

hello world  Is the output from the program we have just ran.
hello world 是我們剛剛運行的程序的輸出。

And Process finished with exit code 0 just lets us know that the program ran without any errors.

而Process finished with exit code 0只是讓我們知道程序運行沒有任何錯誤。

You can refer to HellWorld.py on my GitHub.

Congratulations you have written your first Python program!

Leave a comment if you have any questions and follow on the Python programming series as we move onto more advanced and much more interesting areas of the Python language


No comments:

Post a Comment

how-to-recursively-create-subfolder-in-each-folder-of-a-directory-in-cmd

test.cmd: @echo off setlocal for /f "usebackq tokens=*" %%a in (`dir /b /a:d`) do ( rem enter the directory pushd %%a echo...