Pycharm: 错误 "Cannot perform Refactoring. Function is not under the source root"

Pycharm: Error "Cannot perform Refactoring. Function is not under the source root"

我在windows8上使用pycharm4.0.4,我的项目结构如下:

my_django_project (pycharm content root)
-lib
-docs
-scripts (virtualenv)
-my_project (pycharm source root)
 -tempaltes
 -management
 -models.py
 -views.py
 etc....

pycharm项目翻译:

2.7.2 virualenv at c:\path\to\my_django_project

我正在尝试在我的 models.py 文件中的 class 中执行更改签名重构和方法。

项目解释器设置如上,重命名重构工作完美,但是,更改签名导致 Cannot perform Refactoring. Function is not under the source root"

如果我将 pycharm 项目解释器更改为:

2.7.2 virualenv at c:\Python27\python.exe

所有重构都有效,但是,这不是我的 virtualenv。我究竟做错了什么?为了重构而必须退出 virtualenv 似乎是错误的。

欢迎任何想法,谢谢!

您的项目根目录是否在解释器路径列表中 (Settings| Project Interpreter| Press Cogwheel| More| Show paths for the selected interpreter)?

如果是,则为以下已知问题https://youtrack.jetbrains.com/issue/PY-9285

您可以关注它以获取更新,请参阅操作方法:http://intellij-support.jetbrains.com/entries/23368682

试试这个:Settings -> Project Structure -> Add Content Root,然后 select 您要使用的文件夹。这解决了我的问题。