5

I have purchased PyCharm and am trying to get things to work however I am encountering this issue..

Once I start a project everything works great...

Now if I want a standalone app.. let's say at /users/me/djangoApps I understand I have to add this directory to the python path.. I am trying to do so by creating a file sitecustomize.py at lib/python/2.6/site-packages/

However once I create an app and try to import it I keep getting non excistance errors (yes I have reloaded the python interpreter in pycharm)

I reckon I am adding my locations to the python path in the wrong way.. Also I might not have my project location setup correctly (currently /users/me/djangoProjects)

Thanks,

Novice django'r

4

2 回答 2

10

在 pycharm 中打开设置“cmd”+“”,然后在“项目结构”中单击“源”以包含任何模块。

于 2011-03-24T10:58:54.103 回答
2

不要将该文件添加到您的 python 站点包中,那么您的 django 项目将被包含在以后的所有项目中。

如果要调试,请在 PyCharm 中单击顶部的运行选项卡并选择编辑配置。选择您正在使用的项目,并确保将 manage.py 和 settings.pr 文件所在的目录添加到“工作目录”。所以我认为它可能看起来像这样:

工作目录:/users/me/djangoProjects/{Project Name}

如果您需要将其他内容添加到 Python 路径中,您可以通过转到 File-Settings-Python Interpreter 来添加它,然后在底部窗口中添加一个新路径(但是这将再次被任何项目使用你在 PyCharm 中运行

但是,如果您不是在 PyCharm 中进行调试而只是想运行该应用程序,我发现从命令行运行它会更容易。我假设您在 Mac 上的路径,打开终端并转到您的项目所在的目录(与 manage.py 文件相同的目录)并键入:

python manange.py 运行服务器

如果你想给它一个特定的端口,把它加到最后

python mange.py 运行服务器 9000

这样你就可以在 PyCharm 中编辑你的代码,并且在你保存文件时它会被重新解释。如果您在 PyCharm 中进行调试,则需要停止调试器并再次运行它以提取您的更改

于 2011-02-02T19:36:16.683 回答