====== Python Editor with pydev plugin on Eclipse ====== ===== Install pydev on Eclipse and Configure ===== pydev run with java8 ==== Install Pydev plugin for Eclipse ==== refer: http://www.pydev.org/manual_101_install.html The following assume that you have already Eclipse installed: - You must install **jdk8** to run eclipse - Get Certificate from http://www.pydev.org/pydev_certificate.cer - Go to **Help > Installation details** and look for **'java.home'** . Then to actually import it, in the command line, go to the Eclipse **'java.home'** directory and execute: bin/keytool.exe -import -file pydev_certificate.cer -keystore lib/security/cacerts => your **password** when requested should be **changeit** - Select **Help->Install New Software** to open Eclipse update manager Diaglog. Install PyDev via the Eclipse update manager via the following update site: http://www.pydev.org/updates - Or install via **Help -> Eclipse Marketplace** and **search "pydev"** - Remove: Go to **Help > Installation details > Installed Software** and remove it ==== configuration Pydev on Eclipse ==== - Open in the **Window → Preference → Pydev → Interpreter Python** menu{{:python:xpydev02.png|}} - Press the **New** button and enter the path to python.exe in your Python installation directory{{:python:xpydev04.png|}} - The result should look like the following{{:python:xpydev06.png|}} ===== Your first Python program in Eclipse ===== - Select **Window->Open Perspective ->Other**. Select the **PyDev** perspective.{{:python:xpydev30.png|}} - Select **File -> New -> Project**. Select **Pydev -> Pydev** Project.{{:python:xpydev10.png|}} - Create a new project with the name "de.vogella.python.first". Select Python version 2.6 and your interpreter.{{:python:xpydev20.png|}}Press Finish - Select the "src" folder of your project, right-click it and select **New -> PyDev Modul**. Create a module "FirstModule".{{:python:xpydev40.png|}} ===== Debug ===== * Just right-click in the source code and add a breakpoint. {{:python:xdebug10.png|}} * Then select **Debug as -> Python Run**{{:python:xdebug20.png|}} * You can now inspect and modify the variables in the variables view.{{:python:xdebug30.png|}} Via the debug buttons (or shortcuts F5, F6, F7, F8) you can move in your program. You can use F5 / F6, F7 and F8 to step through your coding. ===== Import pre-Existing python project ===== - Select **Window->Open Perspective ->Other**. Select the **PyDev** perspective.{{:python:xpydev30.png|}} - right click on the project pan and click **import** - From the list expand **General** and select **existing project into workspace**. - Select root directory by going next - Optionally you select **copy projects into workspace** ===== Import scrapy project and debug ===== ==== Import Scrapy Project ==== - Create new pydev project, for example {{:python:scrapy-create-project.png|}} - Copy existing scrapy project to directory myscrapy - Refresh the scrapy project in eclipse {{:python:scrapy-refresh.png|}} ==== Config run and debug scrapy ==== - Go to **Run->Debug Configuration** to open Debug Configuration dialog - Create new configuration myscrapy in menu **Python run** - Config below parameters: * **Main->Main Module**:d:\tools\Python27\Lib\site-packages\scrapy-0.22.2-py2.7.egg\scrapy\cmdline.py * **Arguments->Program Arguments**: crawl dmoz ==== Config run and debug scrapy tests ==== - Go to **Run->Debug Configuration** to open Debug Configuration dialog - Create new configuration scrapyunittest in menu **Python unittest** - Config below parameters: * **Main->Main Module**:d:\tools\Python27\Lib\site-packages\Scrapy-0.22.2-py2.7.egg\scrapy\tests\test_engine.py