Python 3.3 + pygame installation - python-3.x

First, I am aware about the existance of a similar older thread, but honestly, I would not ask, if I found any help there.
Being a simple coding enthusiast, I want to playback media in using python. Since there seems to be no simple solution, a lot of people recommend pygame (or pyglet). So, using win 7 x64, I revert to 32bit Python 3.3.5 and download the presumably correct version of pygame from the super secret download site (pygame-1.9.2a0.win32-py3.3). Both installations work seemingly fine, pygame can locate python (path is set correctly), and finishes its install without issues, yet it seems not to install anything. I cannot import pygame, there are no installed libraries to be found. In pure frustration I tried different iterations of versions, python 2.7, x64, older pygame versions. Nothing worked. I suspect, there is something going on, that may not be connected to the pygame installation, but I don't know what.
import pygame
returns
Traceback (most recent call last):
File "C:/***/pygame_test.py", line 1, in <module>
import pygame
ImportError: No module named 'pygame'

Try using Python 3.2.3 instead of 3.3, along with Pygame for that version: that's what I did, and it works flawlessly on the same system as yours.

You should check up with your installation. Are you sure you installed properly. I have checked on 3.4/3.6/2.7 all works fine. Just install the correct binaries based on your system from http://www.lfd.uci.edu/~gohlke/pythonlibs/.

Download pygame using pip, to be sure that the module is placed in the correct path. Else, put the pygame folder in .\pythonX\Lib\site-packages\. Verify the folder is named pygame and not for example pygame-1.9.2a0.win32-py3.3.

Related

Why does Tkinter work in the terminal but not in Pycharm?

Using Pycharm on Linux mint.
I installed the "future" package for the python interpreter which I'm using. Heres the script.
from tkinter import *
top = Tk()
top.mainloop()
Didn't work. It returns "ModuleNotFoundError: No module named 'tkinter'". Tkinter is infact installed. "python3 -m tkinter" confirms it. And when I compile the same code in the terminal, it displays.
As Bryan says, you're probably not using the Python version you think you're using. PyCharm tends to install its own version of Python. Once you have more than one version of Python installed, things get trickier.
To see what's happening, try running this script:
import sys
print(sys.executable, sys.version)
Or run those similar commands from the command line. That should help clarify matters.
The sys.executable will show you the full path to your Python executable. Great for seeing where the used Python installation is located.
I don't use Python on Linux, but perhaps one of your Python installations is version 2, in which case you would need to use:
from Tkinter import *
which is another way to confirm that the Python is version 2 rather than 3. If this is the case, you'll want to move to Python 3. I don't think anyone writes new projects in Python 2 anymore. It's defunct, purely legacy.
It's also possible that Python is installed on Linux without Tkinter. There are other posts on how to install Tkinter on Linux. For instance, you can check out ImportError: No module named 'Tkinter'
Thanks guys for the help I really appreciate it. But I found out the problem was because of Linux Mint's Software Manager. I initially downloaded pycharm using said software manager but it didnt work which is why I created the post. Then I deleted it, and downloaded pycharm through the tar.gz file from the jetbrains website. After doing that, it seems to work.

I can't figure out how to install PyQt5

I am not a pro, just an amateur enthusiast trying to level up. Apparently I am missing something when it comes to installing PyQt5. In the effort to do so I have gone through several versions of python, and screwed up PyCharm such that it basically doesn't run even my old stuff.
I currently have a 64 bit Python 3.5 and a 32 bit python 3.6 installed. I couldn't figure out where the install file on the latest PyQt5 was, so I used an exe version: PyQt5-5.6-gpl-Py3.5-Qt5.6.0-x32-2.exe
All appeared well, but after this step PyCharm wouldn't work, so I got it to rediscover Python again, but now I get the error:
Traceback (most recent call last):
File "C:/Users/RFC/PycharmProjects/PyQt_learning/test.py", line 2, in <module>
from PyQt5 import QtCore, QtWidgets
ModuleNotFoundError: No module named 'PyQt5'
So, any help would be greatly appreciated!
The first thing I suggest you do is uninstall and redownload the exe. Also after checking the website I have discovered that this version of PyQt5 is only compatible with Python 3.5 not 3.6.

Python 3.6 not finding modules that Python 3.5 can find

I am trying to make a discord bot based on this repository https://github.com/sleibrock/discord-bots
It uses Python 3.6, but when I try to use it I get the error
Traceback (most recent call last):
File "Bot.py", line 9, in <module>
from discord.py import Client, Game
ModuleNotFoundError: No module named 'discord'
In python3.5 >>>import discord runs fine.
In python3.6 >>>import discord gives the same error as above.
Any help would be appreciated.
edit: I copied all files from /usr/lib/python3.5/site-packages and /usr/lib64/python3.5/site-packages to the python3.6 counterparts which seems to have fixed the problem. It seems like it wasn't installing anything into the python3.6 folders and was checking the 3.5 folders, making something break with the import.
Python allows for different versions being installed independently of each other. Each one will have its own packages, which make sense because some packages require a minimal (or specific) version, and packages for Python2 could not work in Python3. In addition, packages using compiled C library will be different between 32bits and 64 bits versions.
It is a feature, because it allows you to install some packages only for one of the different versions you have on your system, but it also mean that you have to install them in all the versions you want to use with them.

How to install PyGObject on windows in a anaconda virtual env

I want to use Gtk with python under windows. I already have Anaconda installed on windows. In order not to mess up everything and to have some easiness uninstalling/reinstalling, I would like to have a virtual env created with conda, working with that Gtk installation. But I don't seems to be able to make it work.
Here is my process. I first create a raw Ananconda virtual env with
conda create -n gtk-exporter python
The virtual environment is located at C:\Anaconda3\envs\gtk-exporter.
I then download the latest windows installer for PyGObject at http://sourceforge.net/projects/pygobjectwin32/files/?source=navbar
I extract and execute the installer and tell it to use a portable python install at C:\Anaconda3\envs\gtk-exporter. I only select Base, GTK and Glade for installation. The installation finished in a second and says it's successful.
Then within windows' shell, I activate the new environment with activate gtk-exporter. However when I try to import gtk, it fails, not finding gi.repository.
>>> from gi.repository import Gtk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'gi'
What's wrong here ? C:\Anaconda3\envs\gtk-exporter\Lib\site-package contains a folder gnome with a lot of stuff including *.dlls, *.exe's and unix-looking folders like etc, lib or share, but I don't see a init.py or something pythonic. Am I missing a step.
Thank you for your help !
The problem was that I used python 3.5, whereas it is not supported. The installer should not have allowed me to install with python 3.5. I filed a bug report to signal it.
I solved the problem by uninstalling python 3.5 and installing python 3.4.

python3 importing pygame results in PyCObject_AsVoidPtr

I have encountered difficulty putting pygame together with python3 on my MacBookPro.
I installed Python 3.3, and my MacOS is running version 10.7.5.
Then I downloaded pygamev1.9.1 source code, and followed instructions in http://programming.itcarlow.ie/PyGameInstall.pdf
Compilation and installation was smooth until I issued "import pygame" inside python3.
Then I encountered the following "PyCobJect_AsVoidPtr" error (further text following error message):
import pygame
Traceback (most recent call last):
File "", line 1, in
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pygame/init.py", line 95, in
from pygame.base import *
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pygame/base.so, 2): Symbol not found: _PyCObject_AsVoidPtr
Referenced from: /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pygame/base.so
Expected in: flat namespace
in /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pygame/base.so
A search on google indicates this symbol has been removed since Python3.2:
http://mail.python.org/pipermail/python-dev/2011-March/108882.html
Can someone please give me some advice on how to get pygame working on Python3.3?
More so, whereas I am aware the pygame/python3 developers are busy with their work, but I would certainly appreciate it if someone can provide precompiled pygame binaries for python3. I have limited computer skills, and I just want to go ahead and learn Python3 and pygame, and this is seriously stunting my interest.
I notice that you were trying to compile from source, but builds on Python 3.3, to my knowledge, are not yet supported (as of January 2013). In fact, the only binaries I'm aware of for PyGame and Python 3.3 are unofficial builds and Windows only.
You should consider instead using a previous version of Python (e.g. Python 2.7.*), PyGame builds/binaries on which are well-supported. Any points on setting up should be directed to the pygame-users mailing list, if they weren't already.

Resources