suddenly I can't import pygame when using pych

2019-08-31 17:03发布

问题:

I am using a Macbook Air with OS X Yosemite.
I am using python 3.4.3.
This morning I opened my laptop and entered import pygame and when I ran the program I got the response:

Traceback (most recent call last):  
File "/Users/Samantha/PycharmProjects/RPG/code.py", line 2, in <module>  
import pygame  
ImportError: No module named 'pygame'

I opened IDLE and also did import pygame and it worked! (perhaps the paths are mixed up?)
For some reason it does not want to work in pycharm anymore.

My pycharm app has been acting quite strange since pygame was "un-import-able"; first it did not want me to create a new python file and then I wasn't allowed to run any of my other programs. please help! thanks

回答1:

You probably have wrong Python interpreter speicfied in PyCharm preferences. Go to

PyCharm -> Preferences... -> Project: project -> Project Interpreter

and from the dropdown list choose your Python interpreter or add it manually if PyCharm is not seeing it.



标签: python pygame