PyCharm: 难以导入包的模块

PyCharm: Difficulties importing module of package

我刚刚开始使用 PyCharm 并从 Eclipse 导入了一个项目。

运行 在 虚拟环境 上,我能够注册一个已编译的 pyd 文件 (PresPy)。但是,我仍然有 "unresolved reference" 错误。我还从 PyCharm 工具提示推荐中安装了 colormath

当运行项目我st运行gely没有pyd相关的错误。相反,解释器抱怨另一个模块而不是 'package level'.

错误 1

未解决的引用:'rgb_color' 在导入语句中:

#  These 4 lines work fine
import copy
import random
from math import pi, degrees
from configuration import Color, Condition #  From custom package

import colormath.color_diff
from PresPy import rgb_color #  Refers to a .pyd.

错误 2

堆栈跟踪:

....

File "x:\proj\src\color_logic\palette.py", line 14, in <module>
    import colormath.color_diff
ImportError: No module named colormath.color_diff

Process finished with exit code 1

内容根目录是项目文件夹。源文件夹位于单独的 /src/ 文件夹中。不完整的 setup.py 存根位于内容根目录中。项目 运行 在 pip install:ed 包的不同安装上没有来自 Eclipse 的错误。

下面,这个 returns 源根文件夹(来自 ):

import os
print os.getcwd()

Project: ... > Project Interpreter1 下,包 colormathPresPy 都是已列出。

1:PyCharm社区版2016.2.3

相关:, 2

解决方法:运行配置必须更改为相应的虚拟环境。