GNU/Linux >> Linux Esercitazione >  >> Ubuntu

Come installare Pygame?

Sto eseguendo Ubuntu 13.10. Ho Python 2.7.5 con anaconda 1.8.0. Ogni volta che avvio python e digito import pygame mi dice che non esiste un modulo chiamato pygame.

Come posso installare pygame?

Risposta accettata:

Il motivo per cui non sei in grado di importare pygame nel tuo interprete python è perché lo stai installando per python2 e avvii l'interprete python3 (Ubuntu 13.10 usa python3 per impostazione predefinita).

Per installare pygame per python2 (la tua versione è 2.7.5), fallo su un terminale (Ctrl +Alt +t ):

sudo apt-get install python-pygame

e quindi avvia l'interprete python2

python2

e quindi prova a importare pygame come

import pygame

Per impostare python2 come tuo interprete predefinito, puoi impostare un alias nel tuo file bash_aliases. Per fare ciò, apri un terminale e digita:

nano ~/.bash_aliases

Questo potrebbe aprire un file vuoto, a seconda che tu abbia impostato un alias prima e poi digita

alias python='python2'

Non modificare i collegamenti simbolici in /usr/bin/python3 , poiché ciò potrebbe interrompere molte applicazioni in Ubuntu 13.10 che usano python3 a gran voce.


Ubuntu
  1. Come installare R su Ubuntu 20.04

  2. Come installare Vai su Ubuntu 18.04

  3. Come installare Jad?

  4. Come installare R su Ubuntu 16.04

  5. Come installare Vai su Ubuntu 18.04

Come installare Vai su Debian 10

Come installare Vai su Fedora 35

Come installare Go in Ubuntu 20.04

Come installare Vai su Ubuntu 22.04

Come installare FreeNAS 11.1

Come installare Vai su Debian