Hi,

I am working with python2.4 on windows, and want pysnmp to be imported.

Have downloaded pysnmp-4.1.14a.tar.gz and pyasn1-0.0.12a.tar.gz and put it under

D:\Python24\Lib\site-packages\. Still i am getting the import error.

from pysnmp.entity.rfc3413.oneliner import cmdgen
ImportError: No module named pysnmp.entity.rfc3413.oneliner

What should I do to make pysnmp importable?

Python's importer does not understand .tar.gz files. You should uncompress the files with 7zip and install the modules properly.

Alternately, you can extract them with python

import tarfile
tar = tarfile.open(mode= "r:gz", fileobj = open("path_to_tgz_file", "rb"))
tar.extractall("path_to_folder_where_to_extract") # for example "."

Edited 5 Years Ago by Gribouillis: n/a

@ Gribouillis.
Thank you. I extracted the files using 7zip before putting it under site-packages.

I still got the import error.
So, I navigated to D:\Python24\Lib\site-packages\pyasn1 and just tried running the module setup.py (i.e., I gave Run module in the IDE). It showed the following error:

Traceback (most recent call last):
  File "D:\Python24\Lib\site-packages\pyasn1\setup.py", line 42, in ?
    apply(setup, (), params)
  File "D:\Python24\lib\distutils\core.py", line 137, in setup
    raise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" % msg
SystemExit: usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: no commands supplied

You should use python setup.py install in a cmd tool. Also you should first move the pyasn1 folder somewhere else on your computer. The setup.py will copy the necessary files to site-packages automatically (you need administrator privileges). Also read the README and INSTALL files if any.

Edited 5 Years Ago by Gribouillis: n/a

From CMD. easy_install pysnmp .
To do this you need to install Setuptools
Or as Gribouillis posted from CMD navigate to folder for unpack files and write python setup.py install

>>> import pysnmp
>>> dir(pysnmp)
['__builtins__',
 '__doc__',
 '__file__',
 '__loader__',
 '__name__',
 '__package__',
 '__path__',
 'majorVersionId',
 'version']
>>> pysnmp.version
(4, 1, 15)
>>>

Edited 5 Years Ago by snippsat: n/a

As Gribouillis suggested, I moved pyasn1 and pysnmp to D:\Python24\ in my PC.

at command line, i used

import os
os.chdir('D:/Python24/pyasn1')
python setup.py install

it's still giving me
syntax error in line 1.

I saw that setup.py has the following interpreter line
#!/usr/bin/env python

I am not understanding where am I going wrong

Edited 5 Years Ago by novice20: n/a

import os
os.chdir('D:/Python24/pyasn1')
python setup.py install

This is wrong.
Do you know what cmd is?
http://www.bleepingcomputer.com/tutorials/tutorial76.html
When you have unpacked files you need to navigate to that folder in cmd.
Then use python setup.py install .
This is one way.

The other are using setuptools as postet before.
It took my 15sek to install pysnmp with setuptools.
This is also done in cmd and not in IDLE easy_install pysnmp

#!/usr/bin/env python

This is only for linux,on windows you dont need that line.

Edited 5 Years Ago by snippsat: n/a

@ snippsat:

Thanks a lot for ur patient and detailed explanation. It helped me a lot. :)

Edited 5 Years Ago by novice20: n/a

Hi,

Was anyone able to get easy_install pysnmp to work with python 2.7.1 and easy install 2.7 on windows? I get the following errors.

C:\Documents and Settings\rudasi>easy_install pysnmp
Searching for pysnmp
Reading http://pypi.python.org/simple/pysnmp/
Download error: [Errno 10065] A socket operation was attempted to an unreachable
 host -- Some packages may not be found!
Couldn't find index page for 'pysnmp' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading http://pypi.python.org/simple/
Download error: [Errno 10065] A socket operation was attempted to an unreachable
 host -- Some packages may not be found!
No local packages or download links found for pysnmp
Best match: None
Traceback (most recent call last):
  File "C:\Python27\Scripts\easy_install-script.py", line 8, in <module>
    load_entry_point('setuptools==0.6c11', 'console_scripts', 'easy_install')()
  File "C:\Python27\lib\site-packages\setuptools\command\easy_install.py", line
1712, in main
    with_ei_usage(lambda:
  File "C:\Python27\lib\site-packages\setuptools\command\easy_install.py", line
1700, in with_ei_usage
    return f()
  File "C:\Python27\lib\site-packages\setuptools\command\easy_install.py", line
1716, in <lambda>
    distclass=DistributionWithoutHelpCommands, **kw
  File "C:\Python27\lib\distutils\core.py", line 152, in setup
    dist.run_commands()
  File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "C:\Python27\lib\site-packages\setuptools\command\easy_install.py", line
211, in run
    self.easy_install(spec, not self.no_deps)
  File "C:\Python27\lib\site-packages\setuptools\command\easy_install.py", line
434, in easy_install
    self.local_index
  File "C:\Python27\lib\site-packages\setuptools\package_index.py", line 475, in
 fetch_distribution
    return dist.clone(location=self.download(dist.location, tmpdir))
AttributeError: 'NoneType' object has no attribute 'clone'

Thanks.

Was anyone able to get easy_install pysnmp to work with python 2.7.1 and easy install 2.7 on windows? I get the following errors.

Yes as you see in my post over that it work,i use python 2.7
You get this Download error: [Errno 10065]
This mean that pypi can be down or problem with port/firwall on your pc.

You can download from pysnmp website and not use easy_install.
http://sourceforge.net/projects/pysnmp/files/pysnmp/2.0.9/
Then you use python setup.py install .

This question has already been answered. Start a new discussion instead.