简体   繁体   English

现有 Python 应用程序的 IntelliJ/PyCharm 项目结构

[英]IntelliJ/PyCharm Project Structure for Existing Python Application

I recently purchased the IntelliJ-IDEA 13 for use of downloading the Python plugin (which I am told has the same code-base as PyCharm) and working on a python web project (specifically Flask).我最近购买了 IntelliJ-IDEA 13 用于下载 Python 插件(我被告知它具有与 PyCharm 相同的代码库)并在一个 Python Web 项目(特别是 Flask)上工作。 I thought it would be a near seamless transfer from Sublime text but I am having some trouble.我认为这将是从 Sublime 文本的近乎无缝传输,但我遇到了一些麻烦。

So here is my problem: I am trying to import an existing Python application (as said earlier that is using Flask) but I cannot set the file correct file structure when importing my project.所以这是我的问题:我正在尝试导入一个现有的 Python 应用程序(如前所述,它使用 Flask)但是在导入我的项目时我无法设置正确的文件结构。

My existing/current project is set up as so (it is modeled after most Flask applications):我现有的/当前的项目是这样设置的(它以大多数 Flask 应用程序为模型):

/Base Directory
    /app
        /static
            *CSS/JS/IMGs go here*
        /templates
            *Templates go here*
        __init__.py
        forms/models/routes.py
    run.py

If you want to see the actual project, it is available on my GitHub Project Page .如果您想查看实际项目,可以在我的GitHub 项目页面找到

IntelliJ apparently has the feature to import existing code into a project, however whenever I go to Import Project , and selecting my Base Directory folder, it always turns out like this: IntelliJ 显然具有将现有代码导入项目的功能,但是每当我转到Import Project并选择我的Base Directory文件夹时,结果总是这样:

当我尝试导入项目时

When I create a New Project -> Flask Project (or any other Python project type) it ends up looking like this:当我创建一个New Project -> Flask Project (or any other Python project type)它最终看起来像这样:

当我创建一个新的 Flask 项目时

The latter is more of what I am looking for (seeing the other files inside of the project, instead of just the root folder).后者更多是我正在寻找的(查看项目中的其他文件,而不仅仅是根文件夹)。

So my question is: Is there a way to adapt my current file structure to work with IntelliJ/PyCharm or vice-versa (and be able to work with the other files)?所以我的问题是:有没有办法调整我当前的文件结构以使用 IntelliJ/PyCharm 或反之亦然(并且能够使用其他文件)? Or is there a quick fix or mistake that I am making?或者是否有快速修复或我正在犯的错误?

Thank you in advance, and remember my project page is here .提前谢谢你,记住我的项目页面在这里

- EpicDavi - EpicDavi

Old Solution旧解决方案

I have found a temporary solution for this for the time being.我暂时找到了一个临时解决方案。

I ended up just creating a new project and copying the files from the old one into the new one.我最终只是创建了一个新项目并将旧项目中的文件复制到新项目中。 This lets me get the project panel like the other projects but is still a hassle moving files around.这让我可以像其他项目一样获得项目面板,但移动文件仍然很麻烦。

This is of course not perfect, seeing as my original project is on GitHub and will have to synchronize the files any time I want to commit.这当然不是完美的,因为我的原始项目在 GitHub 上,并且在我想要提交的任何时候都必须同步文件。

Edit.编辑。 Newer Solution较新的解决方案

Instead of doing the above, I have found that if you create a new Python project inside of the directory of choice (in my case being the Base Directory ) with no other settings, it will set up the project in that area with the necessary files.我发现如果你在选择的目录(在我的例子中是Base Directory )中创建一个没有其他设置的新 Python 项目,而不是执行上述操作,它将使用必要的文件在该区域设置项目. Everything is running smoothly for me.对我来说一切都很顺利。

不完全确定,但 Refactor > Move 不是这种情况的一个选项吗?

如果您使用 Flask,您需要:设置 -> 项目 -> 项目结构和标记为您的项目文件夹在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM