0

I am totally new to programming - I have suceffully got my Raspberry Pi 3b+ to

import pygame

but it fails when I run python3.9, then 'import pygame' fails - it's been driving me crazy as the pygame website recommends to use the latest version of Python!

I must have installed things correctly, updated packages etc. as it works fine in the pi's previous two versions of Python - but why an earth does it not work or recognise the module in Python 3.9?

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
  • Where are your two Python versions installed? Are there any virtual environments involved that save packages in different locations? – Jan Wilamowski Jul 06 '21 at 02:44
  • Hi Jan, the original python versions are installed in /lib/python3 and /lib/python2.7 and /lib/python3.7 while the latest version which I have got working is in /home/pi/Python-3.9.6. I am not using any virtual environments - just raspbian OS on the Raspberry Pi. – Adrian Salt Jul 06 '21 at 03:07
  • 1
    If you execute `python -c 'import pygame; print(pygame.__file__)'` you will see the installation location of the package. If you use Python 3.9 from elsewhere it cannot find it and you should install it again. – Jan Wilamowski Jul 06 '21 at 03:23
  • Ah thank you, this is what I get when entering your command...pi@raspberrypi:~/Desktop/python_work_ii $ python -c 'import pygame; print(pygame.__file__)' `pygame 1.9.4.post1 Hello from the pygame community. https://www.pygame.org/contribute.html /usr/lib/python2.7/dist-packages/pygame/__init__.pyc` Although not entirely sure what to do from here, perhaps I'll just use this old version if it's a lot of trouble to rectify...thanks so much for your help though, much appriciated. – Adrian Salt Jul 06 '21 at 03:55
  • 1
    `"/home/pi/Python-3.9.6" -m pip install pygame` should work (if this is the correct path to your latest python installation). – Twistios_Player Jul 11 '21 at 20:04

0 Answers0