Showing posts with label eclipse. Show all posts
Showing posts with label eclipse. Show all posts

Sunday, June 26, 2016

How To:Set python virtual environment as python interpreter in eclipse

In this lesson we 'll set virtual env as default interpreter in pydev eclipse project.

1). In PyDev Package Explorer panel, right click on project name and select Properties, a new window will open.

2). Click PyDev - Interpreter/Grammar -> Click here to configure an interpreter not listed, a new window will open.

3). Click PyDev -> Interpreters -> Python Interpreter on left panel.

4). In Python Interpreters section click New -> Browse

5). Open virtual environment folder, move to Scripts folder, select python.exe file and click Open.

6). Enter venv in Interpreter Name: instead of default value and click Ok. You can choose name of your own choice.

7). Select newly added python interpreter iPython Interpreters section and click OK

8). Now select newly added python interpreter under Interpreter drop down list and click OK.

How To:Import python project in eclipse

In this lesson we 'll import python django project in pydev eclipse.
Copy these two files from some existing pydev eclipse project to root folder of new project which you want to import in eclipse.
.project
.pydevproject

Open .project file in notepad and change name to your_project_name.
If you don't have these files then you can create them yourself.


Open notepad, copy following text, click File -> Save As... -> Enter ".project" in File name: -> Select All Files from Save as type: drop down list.


<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>your_project_name</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.python.pydev.django.djangoNature</nature>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>

Now again open notepad, copy following text, click File -> Save As... -> Enter ".pydevproject" in File name: -> Select All Files from Save as type: drop down list.


<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?><pydev_project>
<pydev_variables_property name="org.python.pydev.PROJECT_VARIABLE_SUBSTITUTION">
<key>DJANGO_MANAGE_LOCATION</key>
<value>manage.py</value>
</pydev_variables_property>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>/${PROJECT_DIR_NAME}</path>
</pydev_pathproperty>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 3.0</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
</pydev_project>

Open eclipse, click File -> Import. New window will open. Now select 'Existing Projects into Workspace' under 'General' and click Next. On new window browse to project root directory and select root folder. Then click finish.