问题
I'm using mac OsX 10.8.2
, pyCharm 2.7.1
. python 2.7.2
I want to use pygame
package with pycharm
. I followed the instructions on the pygame
site and installed pygame 1.9.1 successfully.
When I write "import pygame" pycharm doesn't find the package.
I tried installing the latest updates of python, pycharm and pygame. I tried using the "install" window in the preferences. It installed "pygamess", "pygameui" and "pyviewx.pygame", but when I try to instal "pygame_loaders" it writes "Install packages failed: Error occurred when installing package pygame_loaders".
If you can please give simple instruction since I'm not a heavy mac-user.
回答1:
To use pygame under OS X, you need to run Python under the 32 bit interpreter. It's usually called something like 'python2.7-32', and if installed from the package on http://www.python.org/, within /usr/local/bin
To get this working in PyCharm, open a project, then preferences ('apple'-'comma'), go to 'python interpreters', and click the '+' button in the right hand pane.
A list should appear and you'll see '/usr/local/bin/python2.7-32', select that and then make it the default for your PyGame project.
If you haven't installed Python from python.org, I recommend you do so; the current version is 2.7.3.
The above setup is how I got PyGame working in PyCharm on Sunday, so it should still be valid.
回答2:
If you have a 2.7 virtualenvs running inside pyCharm you can manual install pygame. Navigate to the virtual env on you disk via the terminal:
cd ~/.virtualenvs/Pygame
Or whatever directory you have. Now we active the virtualenv, just like we normal do when we not work inside pyCharm.
source ./bin/acivate
You should see something like this
(Pygame)mbp-2:Pygame pietje$
Now we can install pygame inside this env.
pip install hg+http://bitbucket.org/pygame/pygame
That's it and everything should work fine inside PyCharm. It does work on my machine :)
来源:https://stackoverflow.com/questions/15464568/pycharm-doesnt-recognize-pygame-package