SNMP support for Python under Windows

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • WIWA

    SNMP support for Python under Windows

    I'm looking for SNMP support in Python. I have found pySNMP, but I'm
    not sure whether this works under Windows as well. A few questions:

    1) Where do I need to install the pySNMP files?
    2) What do I have to do in order to be able to write somethin like:
    "from pysnmp import session"

    Thakns in advance for all input
  • Peter Hansen

    #2
    Re: SNMP support for Python under Windows

    WIWA wrote:[color=blue]
    >
    > I'm looking for SNMP support in Python. I have found pySNMP, but I'm
    > not sure whether this works under Windows as well.[/color]

    Yes, it does.
    [color=blue]
    > A few questions:
    >
    > 1) Where do I need to install the pySNMP files?[/color]

    Doesn't it install with distutils? If so "python setup.py --install"
    or whatever it says in the README would work. Sorry, I haven't
    installed it lately.

    If it doesn't have instructions, put the files under the
    c:/python/lib/site-packages directory.
    [color=blue]
    > 2) What do I have to do in order to be able to write somethin like:
    > "from pysnmp import session"[/color]

    Install, then type "from pysnmp import session".... ;-)
    [color=blue]
    > Thakns in advance for all input[/color]

    (If you're having troubles, please note versions and platform
    next time, for Python, PySNMP, and Windows.)

    -Peter

    Comment

    • WIWA

      #3
      Re: SNMP support for Python under Windows

      Hi Peter,

      Thanks for this useful information. I tried this on my Windows2000
      system and it seems to work. I used distutils and modified the PATH
      entry. I'll check on my Windows XP machine and will let you know if I
      found any discrepancy.

      Thanks again for all your effort. I have another question, but will
      put that in a separate message on this discussion forum. Any help is
      welcome.

      - Wim

      Peter Hansen <peter@engcorp. com> wrote in message news:<3F0CB4ED. C195374F@engcor p.com>...[color=blue]
      > WIWA wrote:[color=green]
      > >
      > > I did two things, both unsuccessfull:
      > >
      > > 1) If I install the pySNMP modules under lib/site-packages and then
      > > type sth like:
      > > from pysnmp import session it gives the error message "ImportErro r: No
      > > module named pysnmp". The same happens if I unstall pySNMP directly
      > > under the lib directory. Installs in this context means 'copy paste'
      > > the *.py files of the pySNMP distribution.[/color]
      >
      > I misled you the first time, but have since taken another look
      > at the installation to see how it works. In order to import
      > anything from a package (roughly, a set of .py files that includes an
      > __init__.py file), you need to put those files in a directory
      > which is named for the package (e.g. pysnmp in this case) _and_
      > which is available in sys.path. (Do "import sys" and "sys.path"
      > to see the list. You probably have lib/site-packages in that
      > list, so just put all the PySNMP files under it in a folder called
      > pysnmp.)
      >[color=green]
      > > - Do I need to explicitly mention in my script where pySNMP is
      > > installed?[/color]
      >
      > Not if it's in a folder called pysnmp that is itself in one of the
      > sys.path folders, or under the current folder.
      >[color=green]
      > > 2) I installed distutils 1.0.2 for Windows and it installed into the
      > > Python directory. So ar so good, I think...[/color]
      >
      > Distutils is included in Python so you probably didn't need to do
      > that, and maybe shouldn't have. I'm not sure whether that will have
      > broken the standard distutils. It's repairable if it did. On my
      > Python 2.2.1 setup here, the standard distutils is v1.0.3.
      >[color=green]
      > > I go to DOS prompt and go to the directory where disutils is installed
      > > and type in python setup.py install, but DOS replies:
      > > 'Python is not recognized as an internal or external command, program
      > > or batchfile".[/color]
      >
      > Now that's a different problem. You need python.exe to be findable
      > from the DOS PATH. The simplest approach might be to check the FAQ
      > entry at http://www.python.org/cgi-bin/faqw.p...=faq08.018.htp
      >
      > As a test of the pysnmp installation, without having to change PATH
      > at all, change to the Python directory ("cd \python" or whatever)
      > and run the interactive interpreter ("python") and just type
      > "import pysnmp" to see if it works.
      >[color=green]
      > > System coordinates are Windows XP. Python version is 2.2.2 and pySNMP
      > > is version 3.0.0.[/color]
      >
      > Should all be no problem, although I suspect instructions in that
      > FAQ entry may be a little light on XP advice. Let us know if you
      > see any area that could be improved so others can benefit from this
      > exchange...
      >
      > -Peter[/color]

      Comment

      Working...