Pygame fonts module, UnboundLocalError [duplicate] - python

I'm using Ubuntu 20.04.1 LTS. I have installed pygame with sudo apt-get install python-pygame. However, when I run my code using VS code, the python terminal gives the output below:
Traceback (most recent call last):
File "path", line 1, in <module>
import pygame
ModuleNotFoundError: No module named 'pygame'
I tried to reinstall Pygame using the same command. Here is the output:
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-pygame is already the newest version (1.9.6+dfsg-2build1).
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
Basically, I already have pygame installed. So what do you think might be the reason? My Python version is 3.8.2.
Thanks in advance!

There isn't a release build of pygame 1.9.6 for Python 3.8.2. Install a development version:
python3 -m pip install pygame==2.0.0.dev10

Related

How to resolve "pygame.error: Couldn't set console screen info" [duplicate]

I'm using Ubuntu 20.04.1 LTS. I have installed pygame with sudo apt-get install python-pygame. However, when I run my code using VS code, the python terminal gives the output below:
Traceback (most recent call last):
File "path", line 1, in <module>
import pygame
ModuleNotFoundError: No module named 'pygame'
I tried to reinstall Pygame using the same command. Here is the output:
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-pygame is already the newest version (1.9.6+dfsg-2build1).
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
Basically, I already have pygame installed. So what do you think might be the reason? My Python version is 3.8.2.
Thanks in advance!
There isn't a release build of pygame 1.9.6 for Python 3.8.2. Install a development version:
python3 -m pip install pygame==2.0.0.dev10

python3 Can't import dbus even though it's installed

I'm trying to use dbus in a python3 project, but when I try to import it, I get an error:
>>> import dbus
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'dbus'
So I tried to fix it by making sure dbus is installed for my python 3.6 installation but it seems to already be installed:
$ sudo apt-get install python3-dbus
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-dbus is already the newest version (1.2.0-3).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
I'm able to import dbus in python 2.7 without any problems, but my python3 can't seem to find the module even though it shows that it's already installed. My which python3 shows it's installed in /usr/local/bin/python3
You are probably getting this error because the path to the module installed by apt-get is not in your sys.path. One solution you can try is this:
import sys
sys.path.insert(0, "/usr/lib/python3/dist-packages")
import dbus

sudo install - Python 3?

I'm new to Linux and I'm trying to install packages through a Makefile so users can run my Python 3 program.
sudo pip install python3-weather-api
However, even after uninstalling a previously installed version, the package seems to be going to the 2.7 version of Python.
Requirement already satisfied: python3-weather-api in /usr/local/lib/python2.7/dist-packages
Then, when I run the program, it can't find the module (it works locally in Python 3 just fine).
SystemExit: 1
Traceback (most recent call last):
File "project.py", line 11, in <module>
from weather import Weather
ImportError: No module named 'weather'
Is there a way I can point the original installation so when I run python3 project.py it can find the module?
Thanks very much!
I would recommend you to use pyenv to manage your Python installations, but, for now, try to run:
sudo pip3 install python3-weather-api

Confusion in Python file execution [duplicate]

I'm using Ubuntu 20.04.1 LTS. I have installed pygame with sudo apt-get install python-pygame. However, when I run my code using VS code, the python terminal gives the output below:
Traceback (most recent call last):
File "path", line 1, in <module>
import pygame
ModuleNotFoundError: No module named 'pygame'
I tried to reinstall Pygame using the same command. Here is the output:
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-pygame is already the newest version (1.9.6+dfsg-2build1).
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
Basically, I already have pygame installed. So what do you think might be the reason? My Python version is 3.8.2.
Thanks in advance!
There isn't a release build of pygame 1.9.6 for Python 3.8.2. Install a development version:
python3 -m pip install pygame==2.0.0.dev10

12.04/13.04 Can't run Pygame [duplicate]

I'm using Ubuntu 20.04.1 LTS. I have installed pygame with sudo apt-get install python-pygame. However, when I run my code using VS code, the python terminal gives the output below:
Traceback (most recent call last):
File "path", line 1, in <module>
import pygame
ModuleNotFoundError: No module named 'pygame'
I tried to reinstall Pygame using the same command. Here is the output:
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-pygame is already the newest version (1.9.6+dfsg-2build1).
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
Basically, I already have pygame installed. So what do you think might be the reason? My Python version is 3.8.2.
Thanks in advance!
There isn't a release build of pygame 1.9.6 for Python 3.8.2. Install a development version:
python3 -m pip install pygame==2.0.0.dev10

Categories