import gammu class - getting error no module named - python

I just want to get status from gammu
import gammu.smsd
smsd = gammu.smsd.SMSD('/etc/gammu-smsdrc')
print smsd.GetStatus()
I saved code to /home/pi/mypython.py
and ran it from terminal
sudo pyhton /home/pi/mypython.py
I'm getting an error
ImportError : No module named gammu.smsd
My target is getting Gammu Status, then if gammu status is stopped I will start it automaticly from other python code.
I was trying:
service gammu-smsd status
Result: No help - just shown usage of gammu-smsd
service --status-all
Result: I'm getting [?] gammu-smsd < unknown is started or stopped
'
Whats wrong with my code? Is there any step I need to do?

The python bindings are separate package, so you need to install it separately even if you already have Gammu installed.

Related

I am getting an error that says: "No module named 'dominate.tags';" even though I have installed dominate

I am trying to run the demo program for the python module Dominate. It is supposed to create an html file using python code.
(python 3.6.13 from microsoft store)
import dominate
from dominate.tags import *
doc = dominate.document(title='Dominate your HTML')
with doc.head:
link(rel='stylesheet', href='style.css')
script(type='text/javascript', src='script.js')
with doc:
with div(id='header').add(ol()):
for i in ['home', 'about', 'contact']:
li(a(i.title(), href='/%s.html' % i))
with div():
attr(cls='body')
p('Lorem ipsum..')
print(doc)
I ran 'pip install dominate' and it installed successfully.
When I try to run this code, it gives me the following error:
I tried to run 'pip install dominate.tags', but it says that there is no such module.
What could be the problem?
Thanks for your help.

PyCharm connecting to console is stuck

I see many have posted the same problem before, but the solutions doesn't help.
I can't run the Console window in PyCharm. I get the error message below shown in the console. And I have set the PATH environment variable using echo %PATH% | clip to copy it. It get stuck at "Connecting to console". What else do I need to do?
\ssl.py", line 98, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: DLL load failed: The specified procedure could not be found.
Process finished with exit code 1

cmd error from python install script?

I'm installing a py script and when installing im getting this error :
"build\temp.win32-2.7\Release\url/url-cpp/src\url.pyd.manifest : general error c1010070: Failed to load and parse the manifest. The system cannot find the file specified.
error: Setup script exited with error: command 'mt.exe' failed with exit status 31"
Can anyone tell me how to fix this?
I have tried the ld_args.append('/MANIFEST') adding to dir>\Lib\distutils\msvc9compiler.py.
Did not work for me. Is there anything else I can do?

Error when testing gpload based on windows

When i try to execute gpload from Windows based ETL host.
Using gpload in a Windows environment produces the following error:
Error I Get:
gpload.py -f gpload.yml
gpload was unable to import The PyGreSQL Python module (pg.py) - DLL load failed with error code 193
You should check whether your pygresql installed correctly or not. Because from the gpload code
try:
from pygresql import pg
except Exception, e:
errorMsg = "gpload was unable to import The PyGreSQL Python module (pg.py) - %s\n" % str(e)
sys.stderr.write(str(errorMsg))
sys.exit(2)
we can know that this is an error about import pygresql (installed or not, version is right ?). If pygresql installed correctly, whether python version or PATH is right ? Please check them.

error while trying to install a package using the python-apt API

I found a code which i need. It is from this link : How to install a package using the python-apt API
#!/usr/bin/env python
# aptinstall.py
import apt
import sys
pkg_name = "libjs-yui-doc"
cache = apt.cache.Cache()
cache.update() # error is in this line
pkg = cache[pkg_name]
if pkg.is_installed:
print "{pkg_name} already installed".format(pkg_name=pkg_name)
else:
pkg.mark_install()
try:
cache.commit()
except Exception, arg:
print >> sys.stderr, "Sorry, package installation failed [{err}]".format(err=str(arg))
However i can't make it work. I searched about the problem on the web. It is said that there should be no package manager,apt,pip etc active in order to work with this code. However, no package manager,apt,pip etc. is open in my computer. I thought that when computer starts, some package manager can be active. So i typed
ps -aux
in terminal and look at the active processes, but i didn't see any active process related to package manager(i'm not %100 sure about this, because any process i don't know can be related to package manager.But how could i know it?) To sum up,i started the computer and opened only terminal. Then i typed python aptinstall.py and hit enter. I take the following error :
Traceback (most recent call last):
File "aptinstall.py", line 7, in <module>
cache.update()
File "/usr/lib/python2.7/dist-packages/apt/cache.py", line 397, in update
raise LockFailedException("Failed to lock %s" % lockfile)
apt.cache.LockFailedException: Failed to lock /var/lib/apt/lists/lock
I delete the lock by giving the command in terminal :
sudo rm /var/lib/dpkg/lock
It didn't work too.
How can i solve this problem? Any idea will be appreciated.
Please try looking for update-manager in ps. It runs automatically on a periodic basis, so it may be locking the apt db.
There are three different reasons which cause this error.
1 - As i mentioned earlier, if any package manager is runnning(for example;pip,apt-get,synaptic,etc), it gives the error.
2 - If you are using your ubuntu in a virtual machine, this causes the same error.
3 - If you are running your program without root privileges, this causes the same error. For example ,if you are running your program with "python aptinstall.py" you get the error, running the program with "sudo python aptinstall.py" is the correct one.

Categories

Resources