pycharm 无法识别 pygame 包 [英] pycharm doesn't recognize pygame package

查看:137
本文介绍了pycharm 无法识别 pygame 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 mac OsX 10.8.2pyCharm 2.7.1.python 2.7.2

我想将 pygame 包与 pycharm 一起使用.我按照 pygame 站点上的说明操作并成功安装了 pygame 1.9.1.当我编写import pygame"时,pycharm 找不到包.

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.

我尝试安装 python、pycharm 和 pygame 的最新更新.我尝试使用首选项中的安装"窗口.它安装了pygamess"、pygameui"和pyviewx.pygame",但是当我尝试安装pygame_loaders"时,它写道安装包失败:安装包pygame_loaders时发生错误".

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".

如果可以,请提供简单的说明,因为我不是重度 mac 用户.

If you can please give simple instruction since I'm not a heavy mac-user.

推荐答案

要在 OS X 下使用 pygame,需要在 32 位解释器下运行 Python.它通常被称为python2.7-32",如果是从 http://www.python 上的包安装的.org/,在/usr/local/bin

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

要在 PyCharm 中实现此功能,请打开一个项目,然后选择首选项('apple'-'comma'),转到python 解释器",然后单击右侧窗格中的+"按钮.

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.

应该会出现一个列表,您将看到/usr/local/bin/python2.7-32",选择它,然后将其设为您的 PyGame 项目的默认值.

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.

如果你还没有从 python.org 安装 Python,我建议你这样做;当前版本为 2.7.3.

If you haven't installed Python from python.org, I recommend you do so; the current version is 2.7.3.

以上设置是我周日在 PyCharm 中使用 PyGame 的方式,因此它应该仍然有效.

The above setup is how I got PyGame working in PyCharm on Sunday, so it should still be valid.

这篇关于pycharm 无法识别 pygame 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆