【发布时间】:2015-09-04 03:02:00
【问题描述】:
abhigenie92@ubuntu:~/Desktop/pygame-1.9.1release$ which python
/home/abhigenie92/anaconda/bin/python
abhigenie92@ubuntu:~/Desktop/pygame-1.9.1release$ sudo apt-get install python-pygame
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-pygame is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 224 not upgraded.
abhigenie92@ubuntu:~/Desktop/pygame-1.9.1release$ python
Python 2.7.10 |Anaconda 2.3.0 (64-bit)| (default, May 28 2015, 17:02:03)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
>>> import pygame
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pygame
上面发生了什么?它似乎没有为 anaconda 安装。但它从路径指向右侧。
【问题讨论】:
-
您是否尝试过从 anacondas 安装的 pip 安装?
-
@Simon 我试过
sudo pip install hg+http://bitbucket.org/pygame/pygame它显示Successfully installed pygame。但仍然 anaconda python 没有显示这样的模块。 -
我不确定 anaconda 是否设置了任何类型的 virtualenv - 我认为确实如此。我不在 linux 上使用 anaconda,但在 windows 上使用 anacondas pip 安装我会这样做:
/home/abhigenie92/anaconda/bin/pip.exe install pygame。 Linux 带有自己的 python 安装,安装 anaconda 将安装第二个,因此您需要导航到 anacondas pip 所在的位置并使用它安装模块。使用sudo pip install pygame只会使用linux自带的基础python