无法在PyCharm中导入pygame

问题描述 投票:1回答:2

[每当我在PyCharm中键入import pygame时,它都表示未安装该模块,但是我可以在python模式下将其导入终端。

python pygame pycharm
2个回答
2
投票

在您的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')

1
投票

如果未正确配置虚拟环境,也会发生这种情况。

© www.soinside.com 2019 - 2024. All rights reserved.