5

I download the gammu source files. My aim is to be able to use the gammu module in my python program. How do I run the setup.py install for python-gammu. Each time I try, I get

running install
running build
running build_py
running build_ext
ERROR: Could not find pkg-config!
f.rodrigues
  • 3,499
  • 6
  • 26
  • 62
Jimmy Ilenloa
  • 1,989
  • 21
  • 21
  • How are you running it? You need to do `python setup.py install` at the command line. – rlms Jul 02 '14 at 12:14
  • Thanks for your swift response. I tried your method, same result. Do I need to install pkg-config. I don't know how that works. – Jimmy Ilenloa Jul 02 '14 at 16:11
  • part of the problem seem to be for the fact that I am running on windows. The **getstatusoutput** function from "commands" appears not to be windows friendly. Reference: http://stackoverflow.com/a/1198935/2259400 I used the new getstatusoutput() implementation from the link. Now I get another error: saying "Unable to find vcvarsall.bat" – Jimmy Ilenloa Jul 02 '14 at 17:59
  • For me, it was easier working with gammu on linux. I could use it in debian linux (Ubuntu and Raspbian - for raspberry pi) – Jimmy Ilenloa Dec 15 '14 at 11:53
  • Ah, the old "vcvarsall.bat" error! That means you need to install Visual Studio, and specifically the version that your version of Python was compiled with (this is an inconvenient thing to do). I'd strongly recommend installing binaries if you can insteadl. – rlms Dec 15 '14 at 19:42
  • @sweeneyrod, thanks. how do I do that? – Jimmy Ilenloa Dec 15 '14 at 22:01
  • You'll need to find them on the internet (they might not be available). – rlms Dec 15 '14 at 22:04
  • 1
    [Here](http://wammu.eu/download/gammu/win32/) are some of the windows binaries. Just install one of the exes. – rlms Dec 15 '14 at 22:05
  • I tried that but in code it says ImportError: No module named gammu – Jimmy Ilenloa Dec 16 '14 at 08:26
  • I tried using gsmmodem module from https://github.com/faucamp/python-gsmmodem. I used this, it worked on ubuntu and windows for me. I still need gammu. It has been a battle for years. – Jimmy Ilenloa Dec 16 '14 at 08:28

1 Answers1

0

You first need to install PIP, after this install python-gammu if you are using linux is way more better than using this on other OS.

the library its pretty simple.

#!/usr/bin/env python
# Sample script to show how to send SMS

import gammu
import sys

# Create object for talking with phone
sm = gammu.StateMachine()

# Optionally load config file as defined by first parameter
if len(sys.argv) >= 2:
    # Read the configuration from given file
    sm.ReadConfig(Filename = sys.argv[1])
    # Remove file name from args list
    del sys.argv[1]
else:
    # Read the configuration (~/.gammurc)
    sm.ReadConfig()

# Check parameters
if len(sys.argv) != 2:
    print 'Usage: sendsms.py [configfile] RECIPIENT_NUMBER'
    sys.exit(1)

# Connect to the phone
sm.Init()

# Prepare message data
# We tell that we want to use first SMSC number stored in phone
message = {
    'Text': 'python-gammu testing message',
    'SMSC': {'Location': 1},
    'Number': sys.argv[1],
}

# Actually send the message
sm.SendSMS(message)

here is a link for more information. http://wammu.eu/docs/manual/python/examples.html

remember that you can do this using the console with no problems at all... the only thing you must remember is to apply a sudo command before sending a message because gammu installs as non root on the system.

Eddwin Paz
  • 2,842
  • 4
  • 28
  • 48