[每当我在PyCharm中键入import pygame
时,它都表示未安装该模块,但是我可以在python模式下将其导入终端。
在您的py脚本中:
import sys
##lets check if this module appears in the sys.path
exist = False
for path in sys.path:
if 'pygame' in path:
print path
exist = True
if not exist:
sys.path.append('... the path to the pygame dir.. where the __init__.py')
如果未正确配置虚拟环境,也会发生这种情况。