pygame-community / pygame-ce

🐍🎮 pygame - Community Edition is a FOSS Python library for multimedia applications (like games). Built on top of the excellent SDL library.
https://pyga.me
828 stars 133 forks source link

Pip install not working for python 3.11 #2378

Closed mshideler71 closed 1 year ago

mshideler71 commented 1 year ago

I was able to pip install pygame-ce to a few versions of python that are on my machine and they all worked, less 3.11. Running programs with the 3.11 interpreter spits back that it doesn't know what pygame.init() means (in VS Code). Change it over to python 3.9 and game runs just fine. Go back to 3.11 and....pygame.init() creates an error.

I pip uninstalled and reinstalled to the 3.11 version and still same error.

Any thoughts on this? Is this a bug with V3.11 not working with pygame-ce?

Thanks!

oddbookworm commented 1 year ago

pygame-ce is 100% fine with python 3.11. It's what I primarily use. Do you also have upstream pygame installed? How exactly are you installing it?

oddbookworm commented 1 year ago

Also, please send the entire error message

oddbookworm commented 1 year ago

In fact, here's a screenshot from my computer right now: image

Starbuck5 commented 1 year ago

Try these commands in this order: pip uninstall pygame pip uninstall pygame-ce pip install pygame-ce

mshideler71 commented 1 year ago

Error with python 3.11.4 64 bit

"Traceback (most recent call last): File "d:\Programming\Python\Udemy-Python_Dungeon_Crawler\main.py", line 6, in pygame.init() ^^^^^^^^^^^ AttributeError: module 'pygame' has no attribute 'init' PS D:\Programming\Python\Udemy-Python_Dungeon_Crawler>"

First six lines:

import pygame
import constants
from character import Character
from weapon import Weapon

pygame.init

Uninstalled pygame via pip and installed to the python by specific version install with, where x was 8, 9, 11): py -3.x -m pip install pygame-ce

Uninstalled pygame from each version the same way: py -3.x -1 pip uninstall pygame

Me just installed it after an uninstall:

C:\WINDOWS\system32>py -3.11 -m pip install pygame-ce Requirement already satisfied: pygame-ce in c:\users\m...

3.11 kick back same error. uninstall, reinstall on 3.9, game runs like it should and gives me the happy shell message: pygame-ce 2.3.0 (SDL 2.26.4, Python 3.9.5)

Pythons installed per python feedback on command line: -3.9-64 * -3.8-32 -3.7-32 -3.11-64

" is 100% fine with python 3.11. It's what I primarily use. Do you also have upstream pygame installed? How exactly are you installing it?"

Just coding along with an udemy course and doing it from a few different ides just to get an idea of the features of each one. they all give the same error when I use 3.11 as the interpreter. All other python programs have worked outside of pygame-ce. strange error when even python tells me that it is installed when I specifically target 3.11

I can also see a folder for pygame-ce in the python 3.11 lib/site-packages folder.

bilhox commented 1 year ago

Since you have several Python versions installed in your computer, do you launch your game with Python 3.11 ?

oddbookworm commented 1 year ago

@mshideler71 try using a virtual environment with python 3.11. That'll keep any environment weirdness from affecting your project environment

mshideler71 commented 1 year ago

Since you have several Python versions installed in your computer, do you launch your game with Python 3.11 ?

Yeap.

I toggle it in VS Code between 3.9 and 3.11. I have used the python Idle for 3.11, I tested it in Thonny and toggled between 3.9 and 3.11 there as well. Geany - 3.9 runs game no problem. Change it to use 3.11, errors out.

mshideler71 commented 1 year ago

"try using a virtual environment with python 3.11. That'll keep any environment weirdness from affecting your project environment"

The virtual environment worked! I think I love you for that one. Will you be my bro-mance? I watched a youtube video on the venv setup and such in VS Code and pygame-ce and it worked immediately. I feel so bad for the people that struggle with things like this and have no idea that venv's are even a possible solution.
Starbuck5 commented 1 year ago

It really just sounds like you installed pygame-ce THEN uninstalled pygame (which removes pygame-ce’s internal files).

oddbookworm commented 1 year ago

I'm closing this issue as it is not actually an issue with pygame-ce

mshideler71 commented 1 year ago

"It really just sounds like you installed pygame-ce THEN uninstalled pygame (which removes pygame-ce’s internal files)."

No.

I just poorly described it. I did every iteration of install, remove everything, just install -ce version get error only in 3.11 then for kicks reinstall regular pygame into 3.11 same issue, uninstall everything, install pygame (non-ce) into the 3.11 and error.

I did it all. I mean pip only takes a few seconds to do its job so the whole testing every iteration of what is installed or not as well as uninstalling both and starting over with -ce only takes a couple of minutes.

oddbookworm commented 1 year ago

What's the output of pip freeze?

mshideler71 commented 1 year ago

"What's the output of pip freeze?"

Didn't use that. do you want me to use that just from the command line? Or when I am in VSC in the venv for the project itself?

oddbookworm commented 1 year ago

It just returns your installed packages. Use that in your global 3.11 environment (the one that you say is broken)

oddbookworm commented 1 year ago

It's a commandline thing (same as when installing something)

mshideler71 commented 1 year ago

Here is the broken (non-venv) output: absl-py==1.0.0altgraph==0.17.2anyio==3.3.4arcade==2.6.15argon2-cffi==21.1.0astroid==2.8.4astunparse==1.6.3attrs==21.2.0auto-py-to-exe==2.20.1automateboringstuff==1.0.2autopep8==1.6.0Babel==2.9.1backcall==0.2.0beautifulsoup4==4.7.1black==22.3.0bleach==4.1.0bottle==0.12.21bottle-websocket==0.2.9cachetools==5.1.0certifi==2021.10.8cffi==1.15.0chardet==3.0.4charset-normalizer==2.0.7click==8.1.3colorama==0.4.4cycler==0.10.0debugpy==1.5.1decorator==5.1.0defusedxml==0.7.1Eel==0.14.0entrypoints==0.3et-xmlfile==1.1.0EZGmail==2022.2.24EZSheets==2021.8.5flatbuffers==1.12future==0.18.2gast==0.4.0gevent==21.12.0gevent-websocket==0.10.1google-api-core==2.7.3google-api-python-client==2.47.0google-auth==2.6.6google-auth-httplib2==0.1.0google-auth-oauthlib==0.4.6google-pasta==0.2.0googleapis-common-protos==1.56.1greenlet==1.1.2grpcio==1.46.3h5py==3.7.0httplib2==0.20.4idna==2.8IMAPClient==2.1.0importlib-metadata==4.11.4ipykernel==6.4.2ipython==7.28.0ipython-genutils==0.2.0ipywidgets==7.6.5isort==5.9.3jdcal==1.4.1jedi==0.18.0Jinja2==3.0.2json5==0.9.6jsonschema==4.1.2jupyter==1.0.0jupyter-client==7.0.6jupyter-console==6.4.0jupyter-core==4.8.1jupyter-server==1.11.2jupyterlab==3.2.2jupyterlab-pygments==0.1.2jupyterlab-server==2.8.2jupyterlab-widgets==1.0.2keras==2.9.0Keras-Preprocessing==1.1.2kiwisolver==1.3.2lazy-object-proxy==1.6.0libclang==14.0.1lxml==4.8.0Markdown==3.3.7MarkupSafe==2.0.1matplotlib==3.4.3matplotlib-inline==0.1.3mccabe==0.6.1mistune==0.8.4MouseInfo==0.1.3mpmath==1.2.1mypy-extensions==0.4.3nbclassic==0.3.4nbclient==0.5.4nbconvert==6.2.0nbformat==5.1.3nest-asyncio==1.5.1notebook==6.4.5numpy==1.21.3oauth2client==4.1.3oauthlib==3.2.0openpyxl==2.6.1opt-einsum==3.3.0packaging==21.0pafy==0.5.5pandas==1.4.2pandas-datareader==0.10.0pandocfilters==1.5.0parso==0.8.2pathspec==0.9.0pefile==2022.5.30pickleshare==0.7.5Pillow==8.4.0platformdirs==2.4.0prometheus-client==0.11.0prompt-toolkit==3.0.21protobuf==3.19.4pyasn1==0.4.8pyasn1-modules==0.2.8PyAutoGUI==0.9.53pyclip==0.6.0pycodestyle==2.8.0pycparser==2.20pygame-ce==2.3.0PyGetWindow==0.0.9pyglet==2.0.dev18Pygments==2.10.0PyInputPlus==0.2.12pyinstaller==5.1pyinstaller-hooks-contrib==2022.7PyJWT==2.4.0pylint==2.11.1PyMsgBox==1.0.9pymunk==6.2.1pynput==1.7.6pyparsing==3.0.9PyPDF2==1.26.0pyperclip==1.8.2PyRect==0.2.0pyrsistent==0.18.0PyScreeze==0.1.28PySimpleValidate==0.2.12python-dateutil==2.8.2python-docx==0.8.10pytiled-parser==2.0.1pytweening==1.0.4pytz==2021.3pywin32==302pywin32-ctypes==0.2.0pywinpty==1.1.4pyzmq==22.3.0qtconsole==5.1.1QtPy==1.11.2requests==2.21.0requests-oauthlib==1.3.1rsa==4.8selenium==3.141.0Send2Trash==1.5.0six==1.16.0sniffio==1.2.0soupsieve==2.3.2.post1stdiomask==0.0.6style==1.1.0sympy==1.9tensorboard==2.9.0tensorboard-data-server==0.6.1tensorboard-plugin-wit==1.8.1tensorflow==2.9.1tensorflow-estimator==2.9.0tensorflow-io-gcs-filesystem==0.26.0termcolor==1.1.0terminado==0.12.1testpath==0.5.0toml==0.10.2tomli==2.0.1tornado==6.1traitlets==5.1.0twilio==7.9.0typing-extensions==3.10.0.2update==0.0.1uritemplate==4.1.1urllib3==1.24.3wcwidth==0.2.5webencodings==0.5.1websocket-client==1.2.1Werkzeug==2.1.2whichcraft==0.6.1widgetsnbextension==3.5.1wrapt==1.13.2yapf==0.32.0youtube-dl==2021.12.17zipp==3.8.0zope.event==4.5.0zope.interface==5.4.0

On Saturday, August 5, 2023 at 01:15:58 PM PDT, Andrew Coffey ***@***.***> wrote:  

It just returns your installed packages. Use that in your global 3.11 environment (the one that you say is broken)

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

oddbookworm commented 1 year ago

Run these commands in exactly this order: pip uninstall pygame-ce pip freeze make sure that pygame-ce is not shown pip install pygame-ce

mshideler71 commented 1 year ago

That  is so bizare that after all that it worked this uninstall / reinstall. Does that pip freeze do something special behind the scenes? That is literally the only change from the half dozen uninstall / reinstall attempts. Earlier today I was literally uninstalling pygame, pygame-ce from all versions of python and installing only pygame-ce and only 3.11 wouldn't work. this time, doing the same thing I did before....works. I did use the: py -3.11 -m pip..... command though.

Of course, now that you mentioned that venv I am really digging that too. I might waste a bit of harddrive space having the same packages in some projects, but hdds are so huge and cheap, who cares? Thanks for all your help today. You're awesome!m

On Saturday, August 5, 2023 at 02:58:03 PM PDT, Andrew Coffey ***@***.***> wrote:  

Run these commands in exactly this order: pip uninstall pygame-ce pip freeze make sure that pygame-ce is not shown pip install pygame-ce

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

oddbookworm commented 1 year ago

pip freeze literally just lists out your installed packages. Nothing else. But this whole thing is exactly the reason I use virtual environments for every single project. It makes dependency management just that much easier

mshideler71 commented 1 year ago

" It makes dependency management just that much easier" I will from now on and forever. I wonder why the Udemy courses or books that I have gone through at the library don't even mention anything about this. After you mentioned it in the comment thread I set it up in about 25 seconds in VSCode after watching a 3 minute video about it. Anyhow, God speed! On Saturday, August 5, 2023 at 04:29:35 PM PDT, Andrew Coffey @.***> wrote:

pip freeze literally just lists out your installed packages. Nothing else. But this whole thing is exactly the reason I use virtual environments for every single project. It makes dependency management just that much easier

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>