ModuleNotFoundError: No module named 'data_receiver' - python

when I go to run my program, I keep receiving the error message below:
pi#navio:~/cloudapp-raspi $ sudo python3 app.py
Traceback (most recent call last):
File "app.py", line 7, in <module>
from data_receiver import DataReceiver
ModuleNotFoundError: No module named 'data_receiver'
however, when I go in the app.py file (see below), I clearly have it being imported.
import logging, time, argparse, configparser, sys
import socket, os, signal, psutil, data_receiver
from subprocess import Popen
from drone import Drone
from connection_watchdog import ConnectionWatchdog
from data_receiver import DataReceiver
from utils import Utils

data_receiver is not a standard python package. If you are installing it from a third party source using a package manager (like pip), be sure to install it globally, i.e., something like sudo -H pip install <package_name>.
Otherwise, if you have a data_receiver.py in your system, make sure to put it in the same directory as your app.py.

Related

Unable to import scapy.all in python while root user

I have a python file named "test_module.py" with the code
from scapy.all import *
and when i execute the file with python test_module.py the module is getting imported successfully but when I run the file using the command sudo python test_module.py it is saying the error
Traceback (most recent call last):
File "test_module.py", line 1, in <module>
from scapy.all import *
ImportError: No module named scapy.all
System info:-
Linux mint 20
Python 2.7.18
So, Please help me to fix this issue.
Did you do
sudo python -m pip install scapy
first ? your issue is likely just having two separate environments
perhaps, try :
pip install scapy
import sys
# and take the correct Path to your scapy , example :
sys.path.insert(1, '/home/Your NAME/anaconda3/lib/python3.8/site-packages/')

Getting an error for a module that I definitely imported

import pyinputplus as pyip
while True:
prompt='Want to know how to keep an idiot busy for hours?\n'
response=pyip.inputYesNo(prompt)
if response=='no':
break
print('Thank you. Have a nice day.')
When I run my above code , I get this error:
Traceback (most recent call last):
File "c:\users\XXXXXX\mu_code\idiot.py", line 1, in <module>
import pyinputplus as pyip
File "c:\users\XXXXXX\mu_code\pyinputplus\__init__.py", line 15, in <module>
import pysimplevalidate as pysv # type: ignore
ModuleNotFoundError: No module named 'pysimplevalidate'
I cannot figure it out. The module is definitely installed. I've even moved it from the folder it was originally installed in to the mu folder where the py file is saved. Any help would be appreciated.
The ModuleError says that you do not have pysimplevalidate installed.
Using the same python executable as you are using to run your script (idiot.py), run
python -m pip install pysimplevalidate
or, even more bullet-proof:
<path_to_python.exe> -m pip install pysimplevalidate
If you are not sure what python executable the script is using, you can check it with
# put this on top of your script
import sys
print(sys.executable) # will print C:\path\to\python.exe

ModuleNotFoundError: No module named 'googlemaps' - though googlemaps installed

I am running an app.py which imports googlemaps as
import googlemaps
But when I do a pip list, it lists googlemaps as
googlemaps 3.0.2
When I run the app,
Traceback (most recent call last):
File "app.py", line 40, in <module>
import googlemaps
ModuleNotFoundError: No module named 'googlemaps'
I am on Windows, Python 3.6.0
In order to be sure. that pip and your script use the same python version I suggest to call following commands from the same terminal window.
python3 -m pip freeze | grep -i googlemaps
python3 -c "import sys ; print(sys.exewutable)"
python3 -c "import sys ; print("\n".join(sys.path))"
Try even following line to prove that googlemaps is installed if not being called from your app
python3 -c "import googlemaps"
and
python3 app.py
If you do not call your app directly with python, then tell us how you start the app. This different way of calling might be why it is not pointing to the same python version / virtualenv than the one where you installed googlemaps
If you do not know how the app is exactly started (e.g. started by a web server or similar), then I suggest you add following lines to app.py
before the import line that fails.
import os, sys
# the next two l
with open(os.expanduser("~/debug.txt", "w") as fout:
fout.write("EXE: %s\n" % sys.executable)
fout.write("PATH:\n" + ("\n".join(sys.path)))
This should create a file named debug.txt,
that you can inspect

pip-18.0 has 'logging module not found' error

Having just upgraded to pip-18.0
all uses of pip produce this error:
...\site-packages\pip\_internal\__init__.py", line 5, in <module>
import logging
ModuleNotFoundError: No module named 'logging'
logging.py exists in \site-packages\pip\_internal\utils\
(and also contains an 'import logging' statement!)
I suppose I could move it up a directory level or update _init to 'import utils.logging'
In fact lots of my programs' packages eg numpy are now failing with no logging module. I have now identified the problem:
import logging
Traceback (most recent call last):
File "", line 1, in
import logging
ModuleNotFoundError: No module named 'logging'
import lib2to3.logging
lib2to3 is a subdir of Lib, containing the logging module,
but is no longer found in the module search.
In my case, running OpenWrt/LEDE 17.01.4 on the client, I had installed most of Python3 via:
opkg install python3-light
when I received the ImportError: No module named logging. I needed to separately install the logging package:
opkg install python3-logging
The above is enough to run the Ansible ping module. To run the setup module you also need:
opkg install python3-multiprocessing python3-distutils
I fixed it by moving logging up from Lib/lib2to3/ to Lib/
where import canm now find it.
I would add to #bitinerant 's answer that also the following package needs to be installed:
opkg install python-openssl python-codecs
for the ping and setup modules to work on python2 based systems

Not able to import module after installing using pip

Im trying to import a module called geoip2 from pypi into python it is not included in its standard libraries.
I open command prompt and type:
pip install geoip2
The command prompt returns
Successfully installed geoip2-2.4.2
After it is installed I try importing it using IDLE:
import geoip2.webservice
which returns the error:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import geoip2.webservice
ImportError: No module named 'geoip2'
Although it is installed already I cannot use it. How can i prevent this? Take note that I use python 3.6
May be you have two different version of Python installed. Try opening IDLE using the Python version where you have installed geoip.
Instead of:
import geoip2.webservice
Try doing:
import geoip2
from geoip2 import webservice
Since geoip2.webservice is not installed, geopip2 is and .webservice is an function object of that module.
Further, you can avoid typing geoip2.webservice every time by doing:
import geoip2
from geoip2 import webservice as gws
Then anytime you want to run the .webservice function, you can just use gws.
Alternatively:
Just do:
import geoip2
Then in your script you can call it:
geoip2.webservice(#do stuff here or however you call the function)

Categories

Resources