Pygame cannnot be imported - python

I've installed pygame using the command pip install pygame. When I enter my python console and so import pygame it gives me ImportError: No module named pygame and then tried installing with sudo apt install python-pygame but I am still facing the same issue. I finally resulted to cloning from https://bitbucket.org/pygame/pygame and build then installing and I'm still getting the import error. Is there any other way available that i could install pygame?

I just found out that running pip install pygame without the sudo would actually install everything from scratch and could now be imported if you run import pygame from the python console. I don't know the reason for that funny behavior but it works for me now.

Related

I am trying to install pygame using pycharm terminal but I get this error [duplicate]

This question already has answers here:
Unable to install Pygame using pip
(27 answers)
Closed last month.
I was trying to install pygame module using pycharm's terminal by typing "pip install pygame" but I am getting this errorinstallation error and yes I have tried running pycharm with admin perms and stuff but it did not work, if you can help then ty!
I just tried to use pygame by typing in my .py file "import pygame" but it say "no module called pygame" and I was simply trying to get a blank window
just upgraded Python to latest version updated pip by using,
pip install --upgrade pip
after that simply run
pip install pygame
Make sure you are using the correct version of python and pygame that both are compatible with each other.
Seems like you don't have admin privilege. Try to open the command prompt with Run as administrator mode or pip install numpy --user

ImportError: No module named pygame, how do you fix this on a mac?

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.

Can't install pygame on pycharm

I've successfully installed pygame on my computer. When I type "import pygame" there is no error so that means that pygame is installed on my laptop. But, when I type the same thing on Pycharm, I get the following error:
ModuleNotFoundError: No module named 'pygame'
I have initialized pygame, so that's not the problem. I've also tried to install pygame from pycharm and I get this error every time I try to install it:
I've tried everything. The interpreter is correct, too. How can I proceed?
Probably you're using two different python interpreters on your pycharm and on your terminal.
Please,
check the python version on the terminal by python3 --version
And then go to pycharm -> file -> settings -> project -> project
interpreter
and check if both python are the same.
sudo easy_install-3.8 pygame
(This will install the dependencies.)
sudo pip3 install pygame

Why i cannot import pygame?

I have this error when I try to import the pygame module all I did was import Pygame my operating system is Linux Ubuntu 14.04 with python 3.6.9 installed.I think the version i'm running but it's difficult for me to change it, this is the error.
import pygame ModuleNotFoundError: No module named 'pygame'
python refers to Python2, so to install it run python3 -m pip install -U pygame --user and execute your script using python3 yourscript.py.
Make sure everything is done through python3 and pip3! Maybe you want to create an alias.

No Module named arcade

For class I am using python arcade. I installed it with pip install arcade. When I attempt to import it with import arcade it pops up ModuleNotFoundError: No module named 'arcade'.
Ive uninstalled and reinstalled arcade. It shows up when I enter pip freeze. I am using VS Code on windows 10.
When I look in the 'errors' tab in VS Code it says "Unable to import 'arcade' pylint(import-error)[3,1]"
I used to have the same problem.
The solution in my case was installing modules by running
python -m pip install <module> instead of pip install <module>
I have the same problem in the jupyter notebook and I have solved it as follow:
pip install notebook

Categories

Resources