I'm trying to install pygame. I now need to type import pygame into the terminal, but then I get this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pygame'
How do I fix this?
You can try this out,
Open Windows explorer
go to the python/scripts folder, where you've saved it.
Over there type cmd in the address bar and then a cmd window with the same directory will pop up
Now you need to go and again install pygame by the following command:
C:\python34\scripts> python -m pip install pygame
Now, the final step is to check it out in your favorite ide by the command.
import pygame
print (pygame.ver)
if it works you're good to go.
Related
Im trying to figure out where the problem is.
When I run the code, I got an error "Traceback (most recent call last):
File "C:\Users\user\IdeaProjects\tiktokAnalyse.idea\main\main.py", line 2, in
import TikTokApi
ModuleNotFoundError: No module named 'TikTokApi' "
Ive installed "pip install TiKTokApi" and imported with
"from TikTokApi import TikTokApi"
Cant figure out where the problem is...
make sure you pip installed it, if the issue is still there, restart the editor. also, check if you have activated the environment in which you pip installed the module(if you are using anaconda)
I'm workin on macOS 10.15.6. I need the Pygame module and I can't seem to import it in a project.
MacBook-Pro:program my_username$ python3 program.py
Traceback (most recent call last):
File "program.py", line 1, in <module>
import pygame
ModuleNotFoundError: No module named 'pygame'
If I try to use import pygame as pygame, I get this:
MacBook-Pro:program my_username$ python3 program.py
Traceback (most recent call last):
File "program.py", line 1, in <module>
import pygame as pygame
ModuleNotFoundError: No module named 'pygame'
When I type pip3 install pygame, I get Requirement already satisfied: pygame in /usr/local/lib/python3.9/site-packages (2.0.1).
I tried to add /usr/local/lib/python3.9/site-packages (2.0.1) to the path using this tutorial.
echo $PATH gives me:
/usr/local/bin:
/Library/Frameworks/Python.framework/Versions/3.8/bin:
/Library/Frameworks/Python.framework/Versions/3.8/bin:
/usr/local/bin:
/Library/Frameworks/Python.framework/Versions/3.8/bin:
/Library/Frameworks/Python.framework/Versions/3.6/bin:
/Library/Frameworks/Python.framework/Versions/3.6/bin:
/usr/local/bin:
/usr/bin:
/bin:
/usr/sbin:
/sbin:
/usr/local/lib/python3.9:
IDLE 3 finds pygame:
>>> import pygame
pygame 2.0.1 (SDL 2.0.14, Python 3.8.6)
Hello from the pygame community. https://www.pygame.org/contribute.html
Can you help me? What should I do to use pygame?
To start, it's highly advised that you check for python virtual environment usage, your project might using venv and the interpreter associated with your project isn't pointing it's PYTHONPATH to the mentioned address.
You can try 2 things:
Use this code at the beginning of your code (Some kind of temporary solution)
import sys
sys.path.insert(0, "/usr/local/lib/python3.9/site-packages (2.0.1)")
Run your python code (assuming you're not using any kind of IDE):
PYTHONPATH=/usr/local/lib/python3.9/site-packages (2.0.1):$PYTHONPATH python3 your-code
As pointed out by the above answer, you may be using a virtual environment. Are you using Pycharm? If so, either create a new project and check use default system interpreter or something on the lines of that.
You could also add modules to the virtual environment by going to File>Preferences (or settings)>Project:(project name)>Python Interpreter, press the + button and search for pygame.
import pyinputplus as pyip
while True:
prompt='Want to know how to keep an idiot busy for hours?\n'
response=pyip.inputYesNo(prompt)
if response=='no':
break
print('Thank you. Have a nice day.')
When I run my above code , I get this error:
Traceback (most recent call last):
File "c:\users\XXXXXX\mu_code\idiot.py", line 1, in <module>
import pyinputplus as pyip
File "c:\users\XXXXXX\mu_code\pyinputplus\__init__.py", line 15, in <module>
import pysimplevalidate as pysv # type: ignore
ModuleNotFoundError: No module named 'pysimplevalidate'
I cannot figure it out. The module is definitely installed. I've even moved it from the folder it was originally installed in to the mu folder where the py file is saved. Any help would be appreciated.
The ModuleError says that you do not have pysimplevalidate installed.
Using the same python executable as you are using to run your script (idiot.py), run
python -m pip install pysimplevalidate
or, even more bullet-proof:
<path_to_python.exe> -m pip install pysimplevalidate
If you are not sure what python executable the script is using, you can check it with
# put this on top of your script
import sys
print(sys.executable) # will print C:\path\to\python.exe
I am a new at Python and I have a roblem with installing one framework.
https://github.com/zalando/connexion
I have already used the command in the terminal 'pip install connexion'
But still when I try to start a programm I get such error:
PS C:\Users\fele\OneDrive\Desktop\Python\Uebergabe\pYTHON_BACKEND_2020_03_12> & "C:/Program Files (x86)/Python37-32/python.exe" "c:/Users/fele/OneDrive/Desktop/Python/Uebergabe/pYTHON_BACKEND_2020_03_12/test_local/test_local_application_hook.py"
Traceback (most recent call last):
File "c:/Users/fele/OneDrive/Desktop/Python/Uebergabe/pYTHON_BACKEND_2020_03_12/test_local/test_local_application_hook.py", line 9, in <module>
from cwsm import connexion_manager
ModuleNotFoundError: No module named 'cwsm'
Cannot anybody give me a suggestion why is it happening?
Thanks in advance
The github page shows:
import connexion
So your import is wrong, try using connexion.
Source:
https://github.com/zalando/connexion#running-it
I am a python newbie who is trying to install packages via pip. I changed the PATH to C:\Python27\Scripts in the Advanced system settings and typed pip in cmd, e.g. pip install pylab. However, after the package being cleaned up, a long red message is pop up as sth similar as follows,
Exception:
Traceback (most recent call last):
(some context)
Storing debug log for failure in C:\Users\Username\pip\pip.log
and when I write "import pylab" in Python 2.7.9 Shell, this message shows up:
Traceback (most recent call last):
File "", line 1, in
import pylab
ImportError: No module named pylab
May anyone tell me what's wrong with it and how I can fix it so that I can install and import modules in python?