#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    10
    Rep Power
    0

    Importing module problem


    I am attempting to import a module called DNS. I installed this module and the module is listed when i run pydoc modules.

    When I run this command the module DNS returns in red and other modules return in white.

    pydoc modules |grep dns

    This is the error.

    I noticed that even though i installed the dnspython module for 3.3 the dns module only lists if I run python and not python3.3

    Traceback (most recent call last):
    File "./2query.py", line 3, in <module>
    import dns.name
    ImportError: No module named dns.name


    Code:
     
    #!/usr/bin/python3.2
    
    import dns.name
    
    n = dns.name.from_text('www.dnspython.org')
    o = dns.name.from_text('dnspython.org')
    print(n.is_subdomain(o))         # True
    print(n.is_superdomain(o))      # False
    print(n > o)                    # True
    rel = n.relativize(o)           # rel is the relative name 'www'
    n2 = rel + o
    print(n2 == n)                  # True
    print(n.labels)                 # ('www', 'dnspython', 'org', '')
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,841
    Rep Power
    480
    Well, there it is. The modules for python3 and python2 are in different directories.

    Before clicking "submit reply" I observe that moving, copying, or linking the python2 modules over to python3 probably won't work. Either install dns for python3 or back port your program to python2.
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    10
    Rep Power
    0
    I discovered that the code I pasted runs fine on a server that only has python2.6 installed. The server with the issues has python2 installed with the distro and also has python3 installed manually.

    The cause of my issues was likely the module not being in my path as I did not specify a path during module install.

IMN logo majestic logo threadwatch logo seochat tools logo