Python Forum
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help im new
#1
I'm new to python, and have basic understanding of a couple coding language like basic operators but I want to learn python extensively because it seems to be a little less whiney about sentax, I'm trying to install pygame which seems to of installed correctly because I'm able to run the alien game example but when I try to import pygame this happens
C:\Program Files>python
Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 17:26:49) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Jeffrey- Admin\AppData\Roaming\Python\Python36\site-packages\pygame\__init__.py", line 133, in <module>
from pygame.base import *
ModuleNotFoundError: No module named 'pygame.base'
>>>



from my basic understanding I think its finding the directory but pygame is trying to refer to a file that doesn't exist
Reply
#2
Your command should be from pygame import *

Though the "*" method is highly discouraged. A better way is either:
from pygame import base

or import pygame then reference in your code >>>pygame.base()
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#3
Your installation is probably wrong(could be mix up 32/64bit),how did you install?
Just pip install pygame should work fine.
Here a test in i a virtual environment i already had open.
(moviepy_env) C:\1\moviepy_env>pip install pygame
Collecting pygame
  Using cached pygame-1.9.3-cp36-cp36m-win32.whl
Installing collected packages: pygame
Successfully installed pygame-1.9.3

(moviepy_env) C:\1\moviepy_env>python
Python 3.6.2 (v3.6.2:5fd33b5, Jul  8 2017, 04:14:34) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
>>> pygame.__version__
'1.9.3'
>>> pygame.base
<module 'pygame.base' from 'C:\\1\\moviepy_env\\lib\\site-packages\\pygame\\base.cp36-win32.pyd'>
>>>exit()
As you see no error,same python version as you 3.6 and 32-bit.
So if should use a wheel it most be for 3.6 and 32-bit,eg from Gohlke pygame.
pip install pygame‑1.9.3‑cp36‑cp36m‑win32.whl
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020