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?
(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.
(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
.
(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.
(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
.
(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.
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.
(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".
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.