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.
Related
So I'm using vscode and I installed python, I changed my python interpreter to Python 3.1 which I assumed would change the Python version to 3.1 as well? But when I type python --version it still says 2.7.18... And I also installed pygame using "python3 -m pip install -U pygame --user" in my terminal but still when I try to run this any file that imports pygame it says ImportError: No module named pygame
Other people have said they have the same problem and maybe I'm missing something but their solutions didn't work for me?
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.
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
Im trying to use the pyperclip module in the idle python editor. When I try to import I get an error saying:
Traceback (most recent call last):
File "", line 1, in
import pyperclip
ModuleNotFoundError: No module named 'pyperclip'
When I try to pip install pyperclip in terminal, I get the following:
Requirement already satisfied: pyperclip in /anaconda3/lib/python3.7/site-packages (1.7.0)
Im brand new to learning python and developing in general, so sorry if this is an easy solution or covered elsewhere that I could not figure out how to find. Im still learning how to most effectively use python so I'm not sure which editor or system I prefer yet. Is there a way to be able to use the pyperclip module in idle without deleting it from anaconda, or removing anaconda entirely?
Im running python 3.7.2 on a Macbook with macOS Mojave 10.14.3.
Thanks!
In terminal, the following
$ python3 -m pip install pyperclip
or similar should install pyperclip or other modules to the python3 installation, where it can be found when you run IDLE with
$ python3 -m idlelib
I expect the same to be true when you start IDLE from the icon or python launcher, but I don't know what changes Anaconda makes to your system.
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.