import module error python3 xubuntu 19.04 - python-3.x

When importing PyGame using the interpreter it is successful. Using Geany it is not.
shows the error.
I have tried editing the shebang, renaming the file. making sure the PATH and version were correct, and that there were no missing Geany plugins.
import pygame
pygame.init()
Error in Geany:
Traceback (most recent call last):
File "moduleerror.py", line 3, in <module>
import pygame
ImportError: No module named pygame

I went into Build >> Set Build Commands and under Execute commands changed
python "%f"
to
python3 "%f"

Related

64bit MacOs After succesfully installing Pygame: ModuleNotFoundError: No module named 'pygame'

Python noob here. I've been trying to install pygame and pandas for a few hours now. Even with Conda I did not succeed. I have Python 3.8.5 installed.
I eventually tried through the terminal with these commands:
python -m pip install pygame==2.0.0.dev6
and
python -m pip install pandas
(this was a total guess by the way, but apparently it did something)
Results were succesfull:
Requirement already satisfied: pygame==2.0.0.dev6 in /opt/miniconda3/lib/python3.8/site-packages (2.0.0.dev6)
and
Successfully installed numpy-1.19.2 pandas-1.1.2 python-dateutil-2.8.1 pytz-2020.1
But, when I try to import either modules, I still get errors. Any ideas?
import pygame
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import pygame
ModuleNotFoundError: No module named 'pygame'
import pandas
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import pandas
ModuleNotFoundError: No module named 'pandas'
Do I need to move the modules to the script folder or something? Or what do I even move? Thanks!
Ok.. Got it thanks to #matt.. after succesfully installing pygame, find the environment in which pygame is installed by entering 'which python'.
In my case it returned:
/opt/miniconda3/bin/python
Now I needed to make sure the VS console was pointing at the same environment, by checking which python interpreter it was using and selecting the correct one. More info:
how to check and change environment in VS Code

Cannont run PyGlossary on Windows10

Absolute noob here, so I apologize in advance for stupid questions.
I'm running Windows 10, I've got Python 3.7.3 and I have...
Successfully installed pyglossary-3.2.1
But I cannot run PyGlossary from the command line or the tkinter GUI. If I run any of the following lines
python3 pyglossary.pyw --help
python3 pyglossary.pyw --ui=tk
python3 pyglossary.pyw --version
Nothing happens and I don't get any sort of error message. I've also tried...
python pyglossary.pyw --help
and I get...
Traceback (most recent call last):
File "pyglossary.pyw", line 30, in
from pyglossary import core # essential
File "C:\mypath\pyglossary\pyglossary.pyw", line 30, in
from pyglossary import core # essential
ImportError: cannot import name 'core' from 'pyglossary' (C:\mypath\pyglossary\pyglossary.pyw)
I've checked Windows Path variables, but I think everything's ok there, and I'm able to run other python stuff. Thanks in advance.

python 3 no module named _tkinter

I've been searching for it but could not find anything on the net on this topic.
When I'm working on a programm in python 3.5 which imports tkinter or pyglet I'm perfectly able to start it from the command line on my Linux Mint installation. As soon as I try to start it from pycharm or Visual Studio Code I get an error.
It is for tkinter:
Traceback (most recent call last): File "/home/b...", line 3, in <module>
import tkinter as tk
File "/usr/lib/python3.5/tkinter/__init__.py", line 35, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named '_tkinter'
Both, the tkinter and the pyglet script, are working when they are started from idle3 (with F5).
Can anyone help me out?
Best
B.
i'm having the same issue. The problem lie with Linux Mint Software Manager. If your vs code is install via Software Manager, it will be install in Flatpak virtual sandbox. Just download and run vs code from its homepage will do.

PyCharm and turtle

I have a problem with PyCharm. I start learning python with PyCharm and I want write some with turtle package. When i try execute this code
import turtle
bob = turtle.Turtle()
I have that message:
"C:\Program Files\Python36\python.exe" C:/Users/Ptr/Desktop/python/Proj_1/Gui.py
Traceback (most recent call last):
File "C:/Users/Ptr/Desktop/python/Proj_1/Gui.py", line 1, in <module>
import turtle
File "C:\Program Files\Python36\lib\turtle.py", line 107, in <module>
import tkinter as TK
File "C:\Users\Ptr\Desktop\python\tkinter.py", line 3, in <module>
okno = tkinter.Tk()
AttributeError: module 'tkinter' has no attribute 'Tk'
Process finished with exit code 1
When I try execute that code using IDLE all works.
In PyCharm I try install turtle in project:
Python>Project Interpreter
but all time I have same error:
Collecting turtle
Using cached turtle-0.0.2.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\Ptr\AppData\Local\Temp\pycharm-packaging\turtle\setup.py", line 40
except ValueError, ve:
except ValueError, ve:
^
SyntaxError: invalid syntax
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\Ptr\AppData\Local\Temp\pycharm-packaging\turtle\
enter code here
A couple of things to note for those running into this at a later time:
tkinter must be installed on your machine. There is a python2.x and
python3.x version. It must match your version of python. For example,
In Ubuntu, I am running python3.6, and had to run apt-get install
python3.6-tk
Pycharm allows you to pick interpreters. It is possible to be running
a different interpreter in IDLE than in PyCharm, making the mismatch
of python and tkinter versions potentially confusing. This is further
complicated potentially by virtual environments. Be certain your
python version and you tkinter versions match.
You can not have modules in your import path of the name tkinter.py or turtle.py
As mentioned by ds_secret, turtle comes with python, no need to
install it separately.
You don't pip turtle. Turtle is a built-in python package.
You just say import turtle.

PyQt5 import Error

I am trying to create a GUI that I can all it from the terminal (Ubuntu here). The problem is, whenever I try to run the code from the terminal, I get the following message:
Traceback (most recent call last):
File "alert.pyw", line 3, in <module>
from PyQt5.QtCore import *
ImportError: No module named 'PyQt5'
The problem is: I only get this message when I try to call the program from the terminal using
python3 alert.pyw Hello
PyQt5 is installed and when I import it from the shell it (apparently) works fine...

Resources