Search code examples
pythoneclipsepydev

How to add the Python nature to a project imported from GitHub?


I just imported a GitHub repository as a new project into Eclipse. Most of the code is Python and I have PyDev installed. When I try to configure a run the Main time always yields this message in the PYTHONPATH area: "Project should have a Python nature". The Run button remains greyed out no matter what.

Assessing the Project Natures tab in Project Properties dialogue I have no option to add a Python nature.

How can run I this project? Thank you.

Update: The contents of the .project file are:

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

And the .pydevproject file:

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

Solution

  • To add a nature manually you can edit the .project file and add:

    <natures>
        <nature>org.python.pydev.pythonNature</nature>
    </natures>
    

    (if there is already a <natures> entry add the <nature> line to that).

    The pydev FAQ section How do I import existing projects/sources into PyDev? covers other files you might need.