Skip to main content
 首页 » 编程设计

python之无法为 anaconda 安装模块

2025年05月04日14me-sa

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 安装。但它是从路径向右指向的。

请您参考如下方法:

您正在将东西安装到系统 Python 中。您需要使用 pip install pygame 安装到 Anaconda Python 中(请注意 sudo pip 可能会再次使用系统 Python,无论如何不建议将 sudo 与 Anaconda Python 一起使用)。