Python Forum
How do I get pygame module to work in Spyder? (Mac)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I get pygame module to work in Spyder? (Mac)
#1
Hey everyone,

My question is how do I get the pygame module to work in Spyder?

pygame is already installed in this path:

/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (2.1.3.dev8)

I get the following error message while trying to import pygame on Spyder:

/opt/miniconda3/bin/python: Error while finding module specification for 'spyder_kernels.console' (ModuleNotFoundError: No module named 'spyder_kernels')

Can anyone help me fix this?
Reply
#2
google "spyder set python interpreter".

This is more about setting up a virtual environment, but it does discuss how to set the python interpreter.

https://medium.com/analytics-vidhya/5-st...click%20Ok.
Reply
#3
(Dec-16-2022, 08:16 PM)deanhystad Wrote: google "spyder set python interpreter".

This is more about setting up a virtual environment, but it does discuss how to set the python interpreter.

https://medium.com/analytics-vidhya/5-st...click%20Ok.

Unfortunately those set of instructions is for Windows, not mac.

I'm having trouble finding the solution for mac.
Reply
#4
(Dec-16-2022, 08:51 PM)FirstBornAlbratross Wrote: Unfortunately those set of instructions is for Windows, not mac.

I'm having trouble finding the solution for mac.
Where use set Python interpreter in Spyder is the same on Mac,it's not a different Spyder on Mac.
Now is set to /opt/miniconda3/bin/python,so you most do Tools → Preferences
Click on Use the following Python interpreter radio button,then point to /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/python.
Reply
#5
(Dec-16-2022, 09:17 PM)snippsat Wrote:
(Dec-16-2022, 08:51 PM)FirstBornAlbratross Wrote: Unfortunately those set of instructions is for Windows, not mac.

I'm having trouble finding the solution for mac.
Where use set Python interpreter in Spyder is the same on Mac,it's not a different Spyder on Mac.
Now is set to /opt/miniconda3/bin/python,so you most do Tools → Preferences
Click on Use the following Python interpreter radio button,then point to /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/python.

Your solution makes logical sense but I have a problem with it.

I can't find the right pathway.

I can't find this specific path:

/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (2.1.3.dev8)

Under site-packages there is:

pygame-2.1.3.dev8.dist-info

But once I open it, there's 7 options to choose from, none of which seem fitting.
Reply
#6
(Dec-16-2022, 09:33 PM)FirstBornAlbratross Wrote: I can't find this specific path:

/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (2.1.3.dev8)

Under site-packages there is:
Look at post again you shall not point to site-packages folder,but to the Python interpreter which is always python.
/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/python.
Reply
#7
(Dec-16-2022, 09:55 PM)snippsat Wrote:
(Dec-16-2022, 09:33 PM)FirstBornAlbratross Wrote: I can't find this specific path:

/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (2.1.3.dev8)

Under site-packages there is:
Look at post again you shall not point to site-packages folder,but to the Python interpreter which is always python.
/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/python.

I tried looking for the "python" path but there doesn't exist one in my folder.
Reply
#8
The path is little strange try look in:
/Library/Frameworks/Python.framework/Versions/3.11/python
Do from this command line.
which python
# Or
python -c "import sys; print(sys.executable)" 
Use python3 if not find python.
Also this will show path.
G:\div_code
λ pip -V
pip 22.3 from C:\python310\lib\site-packages\pip (python 3.10)

G:\div_code
λ pip show pygame
Name: pygame
Version: 2.1.2
Summary: Python Game Development
Home-page: https://www.pygame.org
Author: A community project.
Author-email: [email protected]
License: LGPL
Location: c:\python310\lib\site-packages
Requires:
Required-by:
So for me the root path is C:\python310\python,which i would set in Spyder or any other editors if i want to use this version.
Reply
#9
(Dec-16-2022, 10:54 PM)snippsat Wrote: The path is little strange try look in:
/Library/Frameworks/Python.framework/Versions/3.11/python
Do from this command line.
which python
# Or
python -c "import sys; print(sys.executable)" 
Use python3 if not find python.
Also this will show path.
G:\div_code
λ pip -V
pip 22.3 from C:\python310\lib\site-packages\pip (python 3.10)

G:\div_code
λ pip show pygame
Name: pygame
Version: 2.1.2
Summary: Python Game Development
Home-page: https://www.pygame.org
Author: A community project.
Author-email: [email protected]
License: LGPL
Location: c:\python310\lib\site-packages
Requires:
Required-by:
So for me the root path is C:\python310\python,which i would set in Spyder or any other editors if i want to use this version.

"python" or "python3" does not exist in this directory.

I took a screenshot to show you.

Edit: the screenshot is too big.

pydoc.py
queue.py

That's what's in between "python".
Reply
#10
Use command line(Terminal) and use command that show.
This is basic stuff How to use the Terminal command line in macOS
I guess you used command line to install pygame?
It is pip install pygame.

Here on Windows the command is same on Mac
# pip version and path it install to
G:\div_code
λ pip -V
pip 22.3 from C:\python310\lib\site-packages\pip (python 3.10)

# Install
G:\div_code
λ pip install pygame
Collecting pygame
  Downloading pygame-2.1.2-cp310-cp310-win_amd64.whl (8.4 MB)
     ---------------------------------------- 8.4/8.4 MB 6.7 MB/s eta 0:00:00
Installing collected packages: pygame
Successfully installed pygame-2.1.2
Then path to python is for me(not for you most run same commands).
C:\python310\python that i would set in Spyder.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  keyboard module doesn't work in the microsoft version terminal of python. username 1 2,867 Feb-25-2021, 05:19 PM
Last Post: Larz60+
  pygame music doesn't work CompleteNewb 1 4,717 Jan-30-2021, 09:25 AM
Last Post: Tyrel
  Cannot make 'pandas' module to work... ellie145 2 4,237 Jan-05-2021, 09:38 PM
Last Post: ellie145
  My Python Console doesn´t work ModuleNotFoundError: No module named 'tokenize' RuanKishibe 1 3,180 Aug-06-2020, 10:07 PM
Last Post: deanhystad
  ModuleNotFoundError: No module named 'pygame' Cath 3 14,270 Oct-18-2019, 05:59 PM
Last Post: metulburr
  Pycharm Cannot Find Pygame Module Myang123 2 6,034 Aug-07-2019, 01:26 AM
Last Post: Myang123
  Spyder: Module Not Found jmair 2 20,285 Sep-25-2018, 05:14 PM
Last Post: jmair
  Attribute of module shelve doesn't work Ponomarenko Pavlo 1 5,110 Jul-12-2017, 06:08 PM
Last Post: buran
  Pygame*import pygame ImportError: No module named pygame CASPERHANISCH 1 9,783 Jun-05-2017, 09:50 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020