ImportError: No module named 'urwid' - python

I'm have an issue within a python 2.7 (pypy) script which has the code below
from urwid import ExitMainLoop
It's showing me the error in the title of this question even though it's been installed via pip and can be seen in the output when running pip freeze
urwid==1.3.1
This is running on a Raspberry PI 3 in Raspbian and the same set of scripts are running without issue on a Debian VM.
Any help very much appreciated?

Related

ModuleNotFoundError: No module named 'mysql' with mysql-connector-python already installed

I'm trying to connect my python scripts to an MySQL or MariaDB Server on my RaspberryPi4.
My python script right now just contains import mysql.connector. But when I try to start it via sudo python3 startdb.py I just get import mysql.connector ModuleNotFoundError: No module named 'mysql' as an error.
I get an other error, when I start the script via sudo python startdb.py: import mysql.connector ImportError: No module named mysql.connector.
I searched for a solution on many sites or forums. I mostly just found various versions of pip install mysql-connector-python (also with pip3, mysql-connector-python-rf or mysql-connector) to run but none of them worked for me. The only difference I recognized is that I previously got the error ModuleNotFoundError with both sudo python and sudo python3, but now I only get it with sudo python3.
Does anyone know how to solve this?
Could the fact that my script isn't in a sub-directory of /home/pi/, but instead of /home/, be the problem?
Edit: I just tried executing the script via the desktop mode using my mouse and just clicking on run and it worked. But when I'm using the command line in desktop mode or with a SSH session it doesn't work.
Another Edit: It looks like when I'm starting the script without sudo it'll work just fine. Don't actually know why's that, but I'm good for now. But would be very interesting to know and understand why the sudo makes it "crash".
Thanks and happy to hear some solutions :D
Cooki
raspbian give user mode in running, just in Desktop gives some permission to user for run app as root to access all necessary attributes , use sudo with all initial steps when you download and install project package's

visual studio code can't find my python module i've installes with pip

this might be a very stupid question but I'm a beginner.
I want to use this package called colorgram, it's a module that extracts colours from images, and I installed it using pip via the CMD. but when I try to import it in VS code it can't find it and I don't know what to do, please help
#Andrii Zadaianchuk
sorry, I'm using windows 10. I tried to import it in python in the CMD but nothing either, just the same ModuleNotFoundError: No module named 'colorgram' error.
I did just notice that the modules python version is 3.5 and VS code is running 3.9.2. I think that might be the problem

Python Can't Find Wolframalpha Module

I'm tyring to import wolfamalpha into my code but it gives a error saying:
ModuleNotFoundError: No module named 'wolframalpha'
I tried installing it with pip install wolframalpha, but it still doesn't work.
Here is my code:
import wolframalpha
client = wolframalpha.Client('*************')
When you run your python file, are you sure that you are using the correct python interpreter that you performed the pip install wolframalpha to? It sounds like you may have multiple versions of python on your machine and there is a mismatch. If you are using VSCode, it is easy to see which interpreter is running on the bottom of the screen, which may help you debug the issue.

importing dht11 Adafruit python

I'm having some difficulties importing the module dht11 from the Adafruit library(https://github.com/adafruit/Adafruit_Python_DHT).
I'm using a raspberry pi3 model b, and have installed python 3.5. I downloaded the Adafruit and installed using
sudo python3 setup.py install
and I'm fairly certain that the installation went well since I connected my temp and humidity sensor and using
sudo python3 examples/AdafruitDHT.py 11 2
I get correct reading about temp and humidity, yet when I try to import the dht11 module (I'm using spyder as ide) I get the
'no module named dht11'.
I tried appending the directory in the sys.path but still get the same error.
Edit:
I tried both python 2 and 3, get the same error
Edit2:
I tried other IDE as well, but no one is working.
I opted to launch the script.py directly from terminal since this way it's working. If anyone has a solution, it would be greatly appreciated.

Using Import for PIP Installed Packages While Using Kivy on Windows

I am trying to use the Python module pyowm with Kivy and am having problems getting the import statement to work. I am on Windows 8.1 and downloaded pyowm using PIP. When I try and use "import pyowm" and then send the file to Kivy.bat it says "No module named pyowm" but when I just run a program that uses only pyowm from command line it works.
Any help would be greatly appreciated.
Cheers
The kivy portable package includes its own python, but it sounds like you have installed pyowm into some other python installation.
I haven't used the windows package, but I think somewhere in it there should be a way to run its internal pip. If nobody responds here, someone on the kivy mailing list or irc probably knows.

Categories

Resources