Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import existing project

I created a Django project with just a text editor and the command line, now I have installed Aptana Studio but I cannot import that project. I can create a new django project, pydev is correctly installed and it works.

In Aptana, I tried Import Projects, but it doesnt recognize my project's root directory "No projects are found to import". before replacing settings, models, views, etc,.. with the contents of my project (what I dont like), I want to ask:

Is there a better way to import the project??

You can find a more complete answer Here.

like image 869
juankysmith Avatar asked May 24 '11 16:05

juankysmith


People also ask

How do I Import an existing project?

Click File > Import > General. Click Existing Projects into Workspace. You can edit the project directly in its original location or choose to create a copy of the project in the workspace.

What is Import existing Eclipse project?

Importing an archived file into an existing project jar is a JDK tool for archiving a set of files in a directory so they are stored as a single file. This is very convenient for copying these files. Since a Java program typically contains many files (one for each class), they are typically archived.

How do I Import the same project in Eclipse?

Import an Eclipse project as a module From the main menu, select File | New | Module from Existing Sources. In the dialog that opens, select the directory in which your sources, libraries, and other assets are located and click Open. Select Import module from external model | Eclipse and click Next.


3 Answers

It's a bit dirty but you can do the following. Create two files in your project directory called .project and .pydevproject.

.project should contain:

<?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.pythonNature</nature>
    </natures>
</projectDescription>

and .pydevproject should contain:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?>

<pydev_project>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>\PATH\TO\THE\PROJECT</path>
</pydev_pathproperty>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.6</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
<pydev_pathproperty name="org.python.pydev.PROJECT_EXTERNAL_SOURCE_PATH">
<path>\PATH\TO\EXTERNAL\SOURCES\IF\USED</path>
</pydev_pathproperty>
</pydev_project>

when you've got those two files in your project dir you can use Import>Existing Projects into Workspace

like image 121
berni Avatar answered Oct 23 '22 02:10

berni


This question is answered on the PyDev FAQ page. "How do I import existing projects/sources into PyDev?"

The easiest way seems to go through the File > New > PyDev Project wizard in Eclipse and select as the directory the directory with your sources.

like image 10
Vanja Avatar answered Oct 23 '22 01:10

Vanja


Vanja's answer solved my problem... :-)

How do I import existing projects/sources into PyDev?

If the project was already in Eclipse (i.e.: has the .project and .pydevproject files), use File > Import > Existing Projects into Workspace.

Now, if the project never had the .project nor .pydevproject files, there are 2 choices:

Option 1:

Just go through the File > New > PyDev Project wizard and select as the directory the directory with your sources.

Option 2:

Create the .project and .pydevproject files from the template below and use File > Import > Existing Projects into Workspace to import it. Note that this option is more a reference for people that want to automate creating multiple projects at once.

.project contents (must replace the MyProject with the project name)

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>MyProject</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>

.pydevproject contents (must replace the path (/MyProject/src) with the actual folders to be in the PYTHONPATH)

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse-pydev version="1.0"?>
<pydev_project>
    <pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
    <pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
    <pydev_variables_property name="org.python.pydev.PROJECT_VARIABLE_SUBSTITUTION">
    </pydev_variables_property>
    <pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
        <path>/MyProject/src</path>
    </pydev_pathproperty>
</pydev_project>

How do I import existing projects/sources for a Django project into PyDev?

Follow the same steps in the FAQ above to import a PyDev project, then right click the project > PyDev > Set as Django project and add 2 String substitution variables (on right click project > properties > PyDev PYTHONPATH)

DJANGO_MANAGE_LOCATION, which is the relative path to manage.py. i.e.: src/my_project/manage.py DJANGO_SETTINGS_MODULE, which is the name of the settings module. i.e.: my_project.settings

Note that if the .pydevproject file was created, those values could already be added to it in the entry org.python.pydev.PROJECT_VARIABLE_SUBSTITUTION:

<pydev_variables_property name="org.python.pydev.PROJECT_VARIABLE_SUBSTITUTION">
    <key>DJANGO_MANAGE_LOCATION</key>
    <value>src/my_project/manage.py</value>
    <key>DJANGO_SETTINGS_MODULE</key>
    <value>my_project.settings</value>
</pydev_variables_property>
like image 1
Ajeeb.K.P Avatar answered Oct 23 '22 01:10

Ajeeb.K.P