I am trying to create a game in python, just a beginner, and I installed pygame using the pip command pip install pygame
and it says "requirement already satisfied". So, assuming it is installed, I hop onto VS Code, and the import pygame
to check if it is working, and the ImportError: No module named pygame
error popped up in the terminal, keep in mind I am on a MacBook. Please help. Here is the image of what the error is
Remember to use pip3
on MacOS, pip
is for Python 2.
Try this:
pip3 install pygame
and then run the command:
python3 -c "import pygame"
If the second works, but in VSCode it doesn't, remember to use Python 3, instead of 2 for VSCode.
You shoud try pip3
instead pip
because I remembered that osx already have a version of python2.7(which deprecated). And remember to call CLI
python3 game.py
But I prefer using virtual environment ( venv )than install every packages in your user profile.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.