This question already has answers here:
ImportError: No module named 'pygame'
(25 answers)
Closed 1 year ago.
Im using vs code and when I write the command "pip install pygame" it tells me this "Requirement already satisfied: pygame in /usr/local/lib/python3.9/site-packages (2.0.1)" However, when I try to import pygame it doesnt work. It simply states "line 1, in <module> import pygame ImportError: No module named pygame"
If anyone can help me that would be awesome :)
I think you need to set up your virtual environment. https://code.visualstudio.com/docs/python/environments
But i would recommend you to you use PyCharm, when you create project it automatically creates venv for you and you dont need to care about it.
Related
This question already has answers here:
ImportError: No module named 'bottle' in PyCharm
(9 answers)
Closed 7 months ago.
I'm trying to use the bar_chart_race module from a git respository. The problem is when I do in the terminal
pip install git+https://github.com/programiz/bar_chart_race.git#master
everything seems to work fine and when I try pip freeze the module in pycharm is there. However whenever I try to import the module I get an error saying No module named 'bar_chart_race'
You Have to select the appropriate interpreter in your configuration.
Please check below :
ImportError: No module named 'bottle' - PyCharm
This question already has answers here:
Pylint "unresolved import" error in Visual Studio Code
(40 answers)
PyLint "Unable to import" error - how to set PYTHONPATH?
(33 answers)
Imports failing in VScode for pylint when importing pygame
(3 answers)
Closed 1 year ago.
I’ve downloaded pygame but VS code says, in the problems section , it is “Unable to import ’pygame’ pylint(import-error)”
In the terminal it says “ModuleNotFoundError: No module named ‘pygame’”
What could be causing it to not import?
Edit: I added some more specifics
I'm pretty new to python, but I'll try to give you a solution.
You could create a virtual environment in your terminal. If you don't know how to do that, here's a link to a website I found for macos, https://sourabhbajaj.com/mac-setup/Python/virtualenv.html. For windows, https://mothergeo-py.readthedocs.io/en/latest/development/how-to/venv-win.html. Activate the virtualenv, and then pip install pygame inside the virtualenv, so when you run your code, pygame should work as long as the virtualenv you downloaded pygame in is activated.
I really hope this helps as this is my first time answering a question on stackoverflow!
This question already has answers here:
PyCharm error: 'No Module' when trying to import own module (python script)
(17 answers)
Closed 1 year ago.
I am using PyCharm and am having trouble importing modules
I set up a venv and imported the dependencies via pip install -r
When I try to run the application and get 'module not found' for all imports.
If I open a terminal in PyCharm and do pip list all the required modules are listed
Further PyCharm can file the modules - I can perform completion when typing the name of the module.
What else can I try?
Sounds like you have more than one python environment on your machine.
So, in my opinion, you need to manage the environments in python IDE.
The same happened to me so this helped me in that.
Do check: https://docs.python.org/3/tutorial/venv.html
You can also seek help from the below article:
https://www.freecodecamp.org/news/manage-multiple-python-versions-and-virtual-environments-venv-pyenv-pyvenv-a29fb00c296f/
I solved this by checking the boxes 'Add content toots to PYTONPATH' and #Add source roots to PYTHONPATH'
This question already has answers here:
PIP install a Python Package without a setup.py file?
(2 answers)
Closed 5 years ago.
I am new to python and I am having trouble downloading a module from GitHub: https://github.com/petercerno/good-morning
I have looked online for solutions, but each solution I try does not work. I have tried:
pip install https://github.com/petercerno/good-morning.git
I get an error that says, "Cannot unpack file" & "Cannot determine archive format." I have no idea why I am getting this error.
Just save good_download.py and good_morning.py to the same directory as your Python script, and then import them:
import good_morning
import good_download
# do stuff!
This question already has answers here:
ImportError: No module named 'pygame'
(25 answers)
Closed last year.
I installed python(2.7) using anaconda on an ubuntu machine.
I installed pygame.
When I import pygame I get the error:
ImportError: No module named pygame
Interestingly, when I use /usr/bin/python,
the interpreter now gives no error for import python.
My code file has to run by command python x.py, not in te interpreter.
How could I resolve the issue?
Many Thanks.
Which version are you using? You most import pygame to a Python 2.7 shell.
http://pygame.org/download.shtml is for https://www.python.org/ version 2.7. Make sure you have downloaded and made the setup for Python 2.7 before you coming over and import pygame. If you have followed my steps, I hope you will see:
>>>
Pygame only works for python 2.7 and down. If you downloaded a later version make sure you go into setting in pygame and make sure you have selected python 2.7 to run. You can also do this by making a new project and when you name it scroll down to base interpreter and select python 2.7 since pygames will most likely have selected a higher version of python which will not work for pygames