1. 程式人生 > >linux ubuntu安裝PYGAME的過程和遇到的坑

linux ubuntu安裝PYGAME的過程和遇到的坑

1,PYGAME在官網下載,推薦官網推薦的安裝方式 https://www.pygame.org/wiki/GettingStarted 官網說 The best way to install pygame is with the pip tool (which is what python uses to install packages). Note, this comes with python in recent versions. We use the --user flag to tell it to install into the home directory, rather than globally.

python3 -m pip install -U pygame --user //官網推薦的命令,直接COPY就好

To see if it works, run one of the included examples:

python3 -m pygame.examples.aliens

If it works, you are ready to go! Continue on to the tutorials.

推薦用命令的方式安裝,所以就採用命令

~遇到的問題 1,沒有PIP linux提示安裝pip 2,坑2 安裝了PIP但版本不對,因為有的linux有幾個PYTHON版本,可能安裝到了PYTHON2。7的PIP 所以,一般安裝PYTHON3的

所以,輸入命令

apt-get install python3-pip

PYTHON3的PIP安裝成功後, 再次安裝PYGAME

python3 -m pip install -U pygame --user

測試

python3 -m pygame.examples.aliens