Pygame is installed yet i there is a 'Import Error: No module named 'pygame'
The problem might be that VSCode is running your code with python
not python3
so you will have to install it with pip install pygame
or run it from the console by typing python3 mycode.py
No module named pygame on a python to exe file
pip install pygame
is the command you are looking for.
Run this command in your terminal and then try again.
ImportError: No module named 'pygame' on Ubuntu
Three ways to check this:
1. Using apt-cache
to search and apt-get
to install :
apt-cache search pygame
Result:
python-pygame - SDL bindings for games development in Python
Then install:
sudo apt-get install python-pygame
2. Using pip
:
pip install Pygame
3. Manual installation:
- Download the source from Pypi;
Extract the
.tar.gz
file, and install using:python setup.py install
obs: check the python version you want to install, if you use Python3, use:
pip3 install Pygame
Running python file from command prompt ModuleNotFoundError: No module named 'pygame'
You're trying to execute the script with global python which doesn't have the pygame package installed. So, you have to activate the virtual environment first. To do this, go to venv/Scripts/ and there will be an "activate" file that you need to execute. Once you have done this you can run your script and it should work.
More info on: https://docs.python.org/3/tutorial/venv.html
Related Topics
How to Call a Script from Another Script
How to Safely Create a Nested Directory
How to Install Python Packages [Ssl: Tlsv1_Alert_Protocol_Version]
How to Fix "Runtimeerror: Package Fails to Pass a Sanity Check" For Numpy and Pandas
Identify Groups of Continuous Numbers in a List
How to Count the Frequency of the Elements in an Unordered List
Convert Python Dict into a Dataframe
Text Progress Bar in Terminal With Block Characters
How to Apply a Function to Two Columns of Pandas Dataframe
What Are the Advantages of Numpy Over Regular Python Lists
Converting a List to a Set Changes Element Order
How to Get a Substring of a String in Python
Can't Pickle ≪Type 'Instancemethod'≫ When Using Multiprocessing Pool.Map()