eclipse 导入现有项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6113985/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 16:20:35  来源:igfitidea点击:

Import existing project

eclipseimportideprojectaptana3

提问by juankysmith

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.

我仅使用文本编辑器和命令行创建了一个 Django 项目,现在我已经安装了 Aptana Studio,但无法导入该项目。我可以创建一个新的 django 项目,pydev 已正确安装并且可以正常工作。

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:

在 Aptana 中,我尝试了Import Projects,但它无法识别我的项目的根目录“找不到要导入的项目”。在用我的项目内容(我不喜欢的内容)替换设置、模型、视图等之前,我想问:

Is there a better way to import the project??

有没有更好的方法导入项目??

You can find a more complete answer Here.

您可以在此处找到更完整的答案。

回答by berni

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

它有点脏,但您可以执行以下操作。在您的项目目录中创建两个名为.project.pydevproject 的文件

.projectshould contain:

.project应包含:

<?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 .pydevprojectshould contain:

.pydevproject应包含:

<?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

当您的项目目录中有这两个文件时,您可以使用Import>Existing Projects into Workspace

回答by Vanja

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

这个问题在PyDev 常见问题页面上得到了回答。“如何将现有项目/源导入 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.

最简单的方法似乎是通过 Eclipse 中的 File > New > PyDev Project 向导,然后选择包含源代码的目录作为目录。

回答by Ajeeb.K.P

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

Vanja 的回答解决了我的问题... :-)

How do I import existing projects/sources into PyDev?

如何将现有项目/源导入 PyDev?

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

如果项目已经在 Eclipse 中(即:具有 .project 和 .pydevproject 文件),请使用 File > Import > Existing Projects into Workspace。

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

现在,如果项目从来没有 .project 或 .pydevproject 文件,则有两种选择:

Option 1:

选项1:

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

只需通过 File > New > PyDev Project 向导并选择包含源的目录作为目录。

Option 2:

选项 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 和 .pydevproject 文件,然后使用 File > Import > Existing Projects into Workspace 将其导入。请注意,此选项对于想要一次自动创建多个项目的人来说更像是一个参考。

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

.project 内容(必须用项目名称替换 MyProject)

<?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)

.pydevproject 内容(必须用 PYTHONPATH 中的实际文件夹替换路径 (/MyProject/src))

<?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?

如何将 Django 项目的现有项目/源导入 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)

按照上述常见问题中的相同步骤导入 PyDev 项目,然后右键单击该项目 > PyDev > 设置为 Django 项目并添加 2 个字符串替换变量(右键单击项目 > 属性 > 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

DJANGO_MANAGE_LOCATION,这是 manage.py 的相对路径。即: src/my_project/manage.py DJANGO_SETTINGS_MODULE,这是设置模块的名称。即: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:

请注意,如果创建了 .pydevproject 文件,则这些值可能已经添加到条目 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>

回答by Joe J

If you are using the subclipse (svn) or egit (git) plugins, you may try to create a new project and checkout your code via the git/subclipse wizard. Might be less trouble than trying to import it.

如果您正在使用 subclipse (svn) 或 egit (git) 插件,您可以尝试创建一个新项目并通过 git/subclipse 向导签出您的代码。可能比尝试导入更麻烦。

For example, if using svn:

例如,如果使用 svn:

  1. "File > New > Project..."
  2. Select "Checkout Projects from SVN "
  3. Choose or define your svn repository
  4. On the last page of the "checkout from SVN dialog", select the radio "Open with New Project Wizard" Then follow the wizard steps there to create a project as whatever type you like (django perhaps).
  1. “文件>新建>项目...”
  2. 选择“从 SVN 签出项目”
  3. 选择或定义您的 svn 存储库
  4. 在“从 SVN 对话框签出”的最后一页上,选择单选“使用新项目向导打开”然后按照向导步骤创建一个您喜欢的任何类型的项目(也许是 django)。