I just installed the beta version of Python 3.10
, opened VS Code, changed the Python Interpreter to Python 3.10 64 bit (my PC works with 64 bit) and managed to continue working on my Pygame Project.
Yet, as I runned the code, I faced the ModuleNotFoundError
that said : no module named Pygame.
(though the pygame module is perfectly installed)
So was that because of the beta version of Python? if yes, aren't there some ways to work with pygame and python3.10 at the same time ?
Pygame 1.9 is known to work with python versions 2.4, 2.5, 2.6, and 3.1.
Pygame does not come with Python. Like Python, Pygame is available for free. You will have to download and install Pygame, which is as easy as downloading and installing the Python interpreter.
The Python error "ModuleNotFoundError: No module named 'pygame'" occurs for multiple reasons: Not having the pygame package installed by running pip install pygame . Installing the package in a different Python version than the one you're using. Installing the package globally and not in your virtual environment.
Pygame on Python 3.8 You should use the same command you use to run a Python terminal session on your system, which might be python , python3 , py , python3. 8 , or something else. If you've had any issues running Pygame on macOS, this version of Pygame should address those issues as well.
Pygame is supported for python3.x and has been for a long time. On linux its simply downloading the source and compiling. On windows they have hte wheels for pygame installation on each python 3 minor version.
Python doesn't support Pygame. Pygame needs to support the Python version. I thin it may be a compatibility issue. works just fine. returns a slew of errors. Some of them were pip/pygame bugs having to do with wheels and dependencies. So I cloned the pygame source repository locally and tried to build it from source. works as expected.
The Python 3.10 installer is universal, meaning it runs the ARM64 version of Python 3.10 by default. As Pygame is not yet updated to run on ARM64 you need to run Python 3.10 in Rosetta, to do this from the Shell use command: python3-intel64 To use this in VS Code you will need to alter the settings.json file to:
I just installed the beta version of Python 3.10, opened VS Code, changed the Python Interpreter to Python 3.10 64 bit (my PC works with 64 bit) and managed to continue working on my Pygame Project. Yet, as I runned the code, I faced the ModuleNotFoundError that said : no module named Pygame. (though the pygame module is perfectly installed)
I thin it may be a compatibility issue.
pip3.9 install pygame
works just fine.
pip3.10 install pygame
returns a slew of errors. Some of them were pip/pygame bugs having to do with wheels and dependencies. So I cloned the pygame source repository locally and tried to build it from source.
python3.9 setup.py build;
python3.9 setup.py install
works as expected.
python3.10 setup.py build;
python3.10 setup.py install
reaches the critical limit of 20 errors and decides it's done. I've tried a variety of workarounds and solutions that worked for older versions of both pygame and python but unfortunately nothing has worked, so I think it really is just a compatibility issue and we'll have to wait for pygame to update to work with python 3.10.
For MAC users
The Python 3.10 installer is universal, meaning it runs the ARM64 version of Python 3.10 by default. As Pygame is not yet updated to run on ARM64 you need to run Python 3.10 in Rosetta, to do this from the Shell use command: python3-intel64
import pygame will then work just fine with Python 3.10
To use this in VS Code you will need to alter the settings.json file to:
"python.defaultInterpreterPath" : "/usr/local/bin/python3-intel64"
Then select interpreter from the editor.
If pip install pygame
with python 3.10 produces errors, you could always try again by installing with a .whl file from this website:
https://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame
Installing would probably look like this:
pip install {path-to-whl-file}/pygame-2.0.1-cp310-cp310-win_amd64.whl
I've faced the same issue and VSCode actually explains what is going on, and thanks to @Edster I could solve it.
TL:DR: Set defaultInterpreterPath
to a different value and reset it to python
The description for the option Edster mentioned is:
Path to default Python to use when extension loads up for the first time, no longer used once an interpreter is selected for the workspace. See https://aka.ms/AAfekmf to understand when this is used
And when you go to the link the important information is:
Changes to the python.defaultInterpreterPath will not be picked up by the Python extension once user explicitly chooses a different interpreter for the workspace. The extension will also not set nor change the value of this setting, it will only read from it.
In my case the project was loaded using the unversioned python symlink pointing to 3.9 and then I've downloaded 3.10 and updated my PATH to have python
pointing to 3.10, but when I did that since the value of defaultInterpreterPath
didn't change on VS code it didn't try to pick it up again.
My assumptions are that defaultInterpreterPath
doesn't store the symlink itself but where it points.
python
fixed the issue for me, but I assume if you just disable/enable the Python extension on VSCode it should work.Disclaimer: These are just assumptions and I haven't tried them on my end, feel free to comment here the outcome if you try it or if you have anything to add.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With