GNU/Linux >> Tutoriels Linux >  >> Ubuntu

Comment installer Pygame ?

J'utilise Ubuntu 13.10. J'ai python 2.7.5 avec anaconda 1.8.0. Chaque fois que je démarre python et que je tape import pygame il me dit qu'il n'y a pas de module nommé pygame.

Comment puis-je installer pygame ?

Réponse acceptée :

La raison pour laquelle vous ne pouvez pas importer pygame dans votre interpréteur python est que vous l'installez pour python2 et démarrez l'interpréteur python3 (Ubuntu 13.10 utilise python3 par défaut).

Pour installer pygame pour python2 (votre version est 2.7.5), faites-le sur un terminal (Ctrl +Alt +t ):

sudo apt-get install python-pygame

puis démarrez l'interpréteur python2

python2

puis essayez d'importer pygame en tant que

import pygame

Pour définir python2 comme votre interpréteur par défaut, vous pouvez définir un alias dans votre fichier bash_aliases. Pour cela, ouvrez un terminal et tapez :

nano ~/.bash_aliases

Cela peut ouvrir un fichier vide, selon que vous avez défini un alias avant, puis tapez

alias python='python2'

Ne modifiez pas les liens symboliques dans /usr/bin/python3 , car cela peut casser de nombreuses applications dans Ubuntu 13.10 qui utilisent python3 avec véhémence.


Ubuntu
  1. Comment installer R sur Ubuntu 20.04

  2. Comment installer Go sur Ubuntu 18.04

  3. Comment installer Jad ?

  4. Comment installer R sur Ubuntu 16.04

  5. Comment installer Go sur Ubuntu 18.04

Comment installer Go sur Debian 10

Comment installer Go sur Fedora 35

Comment installer Go dans Ubuntu 20.04

Comment installer Go sur Ubuntu 22.04

Comment installer FreeNAS 11.1

Comment installer Go sur Debian