no module of pygame error about visual studio [duplicate] - python

This question already has answers here:
ImportError: No module named 'pygame'
(25 answers)
Closed 2 years ago.
there, I am newbie, and I am learning pygame, but my Pycharm and Visual studio in Mac always have something wrong of pygame. I have install the pygame with pip, and it is say, 'Requirement already satisfied: pygame in /usr/local/lib/python3.9/site-packages (2.0.1)'. And today I open the Visual studio, 'ImportError: No module named pygame'. Also, the pycharm is there every time if i do a new project I must re-setting the file again to install the pygame packet? why Pygame cannot be a default module but have to set again and again. Because I am living in China and first time to run code and mac Os, if there is any tutorials for me to set the pygame, pycharm, and visual studio, and so much thank you.

Pycharm projects have a virtual environment that may not have access to the same packages as your host system. To make sure pygame is installed on the virtual environment, go to
File > Settings > Project: ____ > Python Interpreter
It will list all packages on the virtual environment. To add pygame if it's not there, go to the + sign in the bottom left corner, type in pygame, and hit Install Package

Related

Why does visual studio code not recognize that i have Pygame installed?

I installed pygame through cmd using pip install pygame which can be seen in the ss. For some reason im unable to import it in my main.py file. Is there some way for me to fix this?(screenshot of terminal and vscode file)
I faced the same issue, but I had used the terminal. What I had done:
Deleted pygame which was installed via pip.
Installed it from the official website.
Then imported pygame. It fixed the issue.
I use linux
Alternatively, you can open the app installer of your device and search "pygame". Hopefully the module shows up.

Pygame 1.9.6 not loading in Python 3.8.1 [duplicate]

This question already has answers here:
Problems getting pygame to show anything but a blank screen on Macos
(10 answers)
Closed 2 years ago.
Really strange issue here. I have a 64bit copy of Python 3.8.1 on my Mac (Catalina 10.15.2). I have successfully installed pygame via pip3 install pygame. Every time I run Python3 and import pygame, I get the successful message of hello from the pygame community....
However, if I run any program that requires an import of pygame, the icon for my python launcher just loops and loads for an infinite amount of time. I get no error messages. I literally get nothing. No opened windows. Just a blank line on the terminal (and IDLE terminal) window after the hello from the... message.
I have on my Mac taskbar a bouncing icon of Python, indicating that it is loading. But nothing happens? I've tested this on every instance of a pygame program with no success. Even the Aliens example embedded within the program does not work.
I had the same issue. Did this in Terminal:
python3 -m pip install pygame==2.0.0.dev6
and in PyCharm I installed pygame package once more into project interpreter with "Specify version" option selected for a specific version: 2.0.0.dev6
Then it started working.

Import openpyxl failing in Pycharm [duplicate]

This question already has answers here:
How do I use installed packages in PyCharm?
(14 answers)
Closed 5 months ago.
Successfully installed the openpyxl module with pip. It imports no problem on the python terminal, but imports fail in Pycharm.
Thought I might have messed up the installation so uninstalled the module and reinstalled.
After reinstalling the second time, checked if python recognized the module and if it works. It passed both those checks. But when using Pycharm and using the import command it doesn't work.
Hoping someone with more experience with Pycharm can help. Attached related screenshots below. I am using Python 3.7 (32-bit).
If I am missing any information or breaking any rules please let me know.
https://imgur.com/a/2A5VymR
Thank you all in advance.
Uninstall Pycharm
Reinstall Pycharm but with this setting make sure to click on "add launchers dir to the PATH"
Installing setting:

Installing PyGame - ImportError: DLL load failed

My current version of Python is the newest 3.5 and the only available PyGame was for 3.2 (both PyGame and Python are 32-bit). I've scoured stackoverflow for a resolution and can't find any way to make this work. I've installed the PyGame easy installer and placed it in the directory where my Python install is, and in Visual Studio (I've also tried this in PyCharm as well as the standard Python IDE in command prompt), upon typing
import pygame or import sys, pygame
I'm presented with the error Import Error was
unhandled by user code - DLL load failed: The specified module could not be found.
My final solution is to uninstall Python 3.5 and install the version which matches PyGame.
This shouldn't have anything to do with Python version. You are missing a dynamic library (the DLL). This means that either the DLL is not on your system or Python can't find it. You should probably try the msi/exe installer for PyGame mentioned here, as it should install any dependencies. This would fix the issue if it is caused by the DLL being absent from your system.
It could also be caused by the libraries not being on PYTHONPATH. Search the error you received and you should see quite a few answers on fixing this.
If you're just getting started, you may want to look at a different library. There are likely quite a few game libraries for Python that can be installed with a simple pip install. You could then return to PyGame when you are more comfortable if you wanted.
get it from here: https://www.dropbox.com/s/hnmcaq1rf6zn7m3/pygame-1.9.2a0-cp34-none-win32.whl?dl=0
download it and install it by putting it in C:\python3.5\Scripts
then run pip3 install pygame-1.9.2a0-cp34-none-win32.whl
(this is for 3.4, but 3.5 works too)
it should work, and your error has nothing to do with the package, it's just that you do not have a DLL file, install it again from the website above

pygame import error in eclipse

when I import pygame using eclipse on my mac, there's a import error:
However, I can still run this program correctly, So what can I do to fix it?
to quick fix you can do:
PyDev Package Explorer>right click your project>properties>PyDev - PYTHONPATH>External Libraries>Add source folder>PythonX.X(version where you installed pygame)/Lib/site-packages/pygame
this will include one external library for this project, but you should check if you are working with the right python version you installed.
I have 3 versions of python, pygame is only on Python2.6, so all my new projects that use pygame must have python2.6 syntax and interpreter python26.
To check your interpreter settings:
Window(menu)>Preferences>PyDev>Interpreter - Python>New>interpreter name you can put anything you may remember, interpreter executable find the python.exe and put the path there, OK.
Now you have added the entry for the interpreter, if you look down in the same window, into Libraries you can add many packages you want the interpreter to look for to resolve names and syntax.
They make Pygame for every version of Python. I have it for Python 3.4 it came out in March 2014. If you are getting the error there is no module named Pygame. It is because Pygame is not in Python's path or you have the wrong version of Pygame for your current version of Python. You can find more Pygame downloads here that arnt on pygame.org. Click on the blue word Pygame at the top and it will take you to the proper section of the page.
http://www.lfd.uci.edu/~gohlke/pythonlibs/
Download the one you need for your Python version. If you hold the mouse over it it should show more info about the version in a tiny pop up. I am on windows but it found the path by itself. I'm not sure if it will for mac.

Categories