I have downloaded pygame for 64 bit and when I try to import pygame , I keep on getting the following error.
Traceback (most recent call last):
File "D:\Python\test 2\test_2.py", line 4, in <module>
import pygame
ImportError: No module named 'pygame'
Note
According to http://www.pygame.org/download.shtml
NOTE: if you
had pygame 1.7.1 installed already, please uninstall it first. Either
using the uninstall feature - or remove the files:
c:\python25\lib\site-packages\pygame
Direct download link for python
Downoad link for python 2.7.11 ===> Here
Direct download link for pygame
Download link for pygame ===> Here
Make sure you install the correct python version and pygame version.Dont mix up the two.
The links I have provided are ONLY for windows and not any other operating system.
Well, you need to make sure you are downloading the correct version of pygame with python. Try redownloading pygame, and when your downloading it should say if it finds the proper python in the directory, if it doesn't theres a problem with the version you/your downloaded/downloading.
Related
I have recently bought a new laptop and was viewing some python projects of mine which I made on my pc. For one of them I use the python-bitvavo-api library which I installed using pip3 install python-bitvavo-api. The version I installed is 1.2.2 which is the latest on their website.
Now when I try to import it using this code: from python_bitvavo_api.bitvavo import Bitvavo, I get the following error:
Traceback (most recent call last):
File "C:\Users\indig\OneDrive\Documenten\Python Projects\Personal\Cryptone\Cryptone.py", line 6, in <module>
from python_bitvavo_api.bitvavo import Bitvavo
ModuleNotFoundError: No module named 'python_bitvavo_api'
I read online that it may occur when using multiple python versions, Im only using 1 and thats python 3.7
Btw. I have the same error with the Pillow module, so it might be a setting in visual studio that I dont know of. Anyway, someone please help. If you need more details please ask.
How are you running it? From the terminal or from VS?
You can also check the installed libraries running the command pip list
so i've recently installed pygame because i want to start programming with it. Before writing code, i decided to just make sure its running fine by testing it in IDLE.
i ran
import pygame
no error
i ran
pygame.init()
and got the following error
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
pygame.init()
AttributeError: module 'pygame' has no attribute 'init'
by doing some research i found out that it may be messing up the path, so i tried
pygame._path_
and got a similar error
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
pygame._path_
AttributeError: module 'pygame' has no attribute '_path_'
and i can't figure out whats wrong. i've tried solutions in other questions but nothing works
im using
Windows 10 Home
Python 3.5.2 32 Bit
Pygame 1.9.2a0 for python 3.2 (but after looking up if it would work with python 3.5, i found resources saying it would)
i tried installing the 3.5 version as a .whl but it had its own host of problems and just decided to use the installer. is the error because of the mismatch between python versions and pygame versions, or is there something else i can try?
I have tried the following
pygame._path_
there is nothing else named pygame.py that would confuse the path
i used the installer
i made sure there were no other versions of python/pygame installed
So are there any other solutions beyond the ones that i have tried to get this one working?
Thank you for your time.
EDIT 1: I have made sure that the only directory named pygame is the module.
to finding the pygame path:
Magic methods have two underscores on either side of them.
to the lack of pygame.init():
different software seem to be able to find different parts of pygame, because PyCharm cannot locate that function, but when running off the command line it operates perfectly. It may just be a fault of idle. Try running from the command line or double clicking the .py file, assuming it is associated with the interpreter. If that doesn't work, run the command
python -m pip install --upgrade pygame
Have you installed pygame correctly.
Put this in your cd (command prompt) to check if you have installed pygame properly
py -m pygame.examples.aliens
If it gives a error then you should use the pip install function
py -m pip install -U pygame --user
If everything fails you can install an IDE. I would recommend pycharm https://www.jetbrains.com/pycharm/download/#section=windows
It is a free IDE and you can install pygame from there for a project
File --> Settings --> Project:(Name) --> Project Interpreter --> pip --> type pygame and install package.
Pycharm pygame installation
I`m having some issues installing Pygame. I am running a 64 bit Windows 8 system, with a 32 bit version of Python 3.4.
Here is how I have been trying to install it so far:
I have visited http://pygame.org/download.shtml and downloaded the file called pygame-1.9.2a0.win32-py3.2.msi.
I have executed the file and selected 'Install for all users'.
At this point it asks me to select a Python location into which I should install Pygame. I then select 'Will be installed on local hard drive' from the dropdown. A text box asks me to input an alternate Python location. This is set to C:\PythonX. I set it to my Python location - C:\Python34.
I finish the installer and go to the shell. I input import pygame into the command line. It gives the following error:
Traceback (most recent call last): File "", line 1, in
import pygame File "C:\Python34\lib\site-packages\pygame__init__.py", line 95, in
from pygame.base import * ImportError: DLL load failed: The specified module could not be found.
If I look in the Python34 file after the install, I find the Pygame folder in the location C:\Python34\Lib\site-packages\pygame.
Any help would be greatly appreciated.
Installing from MSI and not pip make sure you get the correct version that matches your set up of Python.
you are running a 64 bit Windows 8 system, with a 32 bit version of Python 3.4.
you downloaded the 32 bit version of Pygame for Python 3.2 you need the one for the Python 3.4 version.
This one from official bitbucket should work as it is the correct version for python 3.4 32 bit compatibility.
https://bitbucket.org/pygame/pygame/downloads/pygame-1.9.2a0-hg_5974ff8dae3c+.win32-py3.4.msi
This question already has answers here:
i keep getting the error 'module' object has no attribute 'init' [duplicate]
(2 answers)
Closed 4 years ago.
I downloaded pygame successfully but now when I do:
import pygame
pygame.init()
size = [400, 400]
pygame.display.set_mode(size)
it gives errors:
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module> pygame.init AttributeError:
'module' object has no attribute 'init'
And nothing is working for me. Please help me use init and display.
I am using
python 3.4.1 and
pygame 1.9.2 on
Windows 7 32bit and
I installed pygame on
c://python34/include/
You probably had named your file pygame.py
when you type:
import pygame
python won't import pygame module you want, instead it will try import local module pygame - your file. and your file hasn't method init.
try change file name from pygame.py to mypygame.py.
I had the same problem, but then I reinstalled everything and realized that I had a different version of pygame than I needed for python
I realized also that I shouldn't use the .zip archive to install. I looked in there and saw that there's an installer for it if you're on any major OS. For example, for Macintosh, there's .dmg files. For Windows, there's .msi, etc.
You probably installed your pygame library in the include/ folder, but somehow didn't have the correct files inside it. This may of happened because of some downloading issues or the website you were downloading from. Hope this helps! You want to type downloading pygame from pygame.org instead of some other places on the web because of possible errors or changes in code.
I followed what they said at pyside.org but somehow i can't get it to work.
I downloaded the two files that they are linking from their site (qt libraries and pyside for python 2.6)
When I try one of their examples I get the following message:
Traceback (most recent call last):
File "2dpainting.py", line 28, in <module>
from PySide.QtCore import *
ImportError: DLL load failed: The specified module could not be found.
I use python 2.6.4 and windows 7
You need to add the QT bin directory ("C:\Qt\4.6.3\bin") to your path environment variable.
The situation with Windows binaries significantly improved in 1.0.0 release. Try newer installers from downloads page.
There is a similar question on Installing PySide - Windows 8
You can simple use
pip install PySide
to install it.